What is the reliable way of implementing bidirectional communication to a Linux process?
I see that popen does not seem to support “r” and “w” access at the same time… or at least that’s what is implied:
The type argument is a pointer to a null-terminated string which must be either 'r' for reading or 'w' for writing.
(I am so missing Erlang at the moment)
Unix domain sockets are your friend.
You reserve a name for your communications channel, such as
/myapp/ipc, and then both processes open that address using a UNIX socket:Now you can use
listenorconnector whatever else in the socket family. It’s a little bit of work, but is the best way to achieve IPC on Linux.Since Erlang is just a nice language for specifying little servers (processes) that communicate over named pipes (processes), this model should feel comfortable to you.