file_fifo_test/README.md
2023-06-05 14:20:40 +03:00

1003 B

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:

  1. 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.

  2. Default lua io module does not provide ways to make the read() from fifo non-blocking. Makes it less useful, but maybe still possible to use with async environment?