whosit 6e5e51bd2c | ||
---|---|---|
README.md | ||
init.lua | ||
process.py |
README.md
This is just a proof of concept for a way of communicating with an
external process using unix fifo files (created by mkfifo()
call).
Main point: this does not require insecure environment. It only uses
default "safe" io.open
.
Usage:
First, cd into world directory and launch process.py
:
python ../../mods/file_fifo_test/process.py
This will create in the current working directory a pair of FIFO files for input and output.
Then start the server. Exchange should begin as soon as both ends of FIFO are open. Exchange is done in a lock-step fashion at the moment, but maybe using async env can fix that (see Problem 2).
Problems:
-
If output fifo is closed on the other end, then
output_fifo:write()
will crash the MT. I don't see a way to check if it's safe to call write or not. -
Default lua
io
module does not provide ways to make the read() from fifo non-blocking.
Solutions:
- This patch applied minetest will prevent crashing caused by writing to closed pipe:
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -122,6 +122,7 @@ void signal_handler_init(void)
{
(void)signal(SIGINT, signal_handler);
(void)signal(SIGTERM, signal_handler);
+ (void)signal(SIGPIPE, SIG_IGN); // ignores SIGPIPE to not terminate on write to a closed fifo
}
#else // _WIN32
It just ignores SIGPIPE
, which should be fine to do.
- It's possible to do
read()
in async environment.