Problem:
There is a C application that calls a Bash script each time an event happens. And there is also a C++ application that needs to track down those events. The C++ application is driven by a select() event loop. What would be the most simplest IPC to implement between Bash script and C++ application?
C Application ---Each time calls Bash script---> Bash application ---???---> C++ Application
Few solutions that came into my mind:
- To use TCP networking sockets, but this would mean that select will have to handle events for both Listening and Actual sockets
- To use Named pipes, but once the bash script terminates then the other end of the pipe is closed as well
Is there something simpler that would allow me to use only one File Descriptor in select()?
Unix datagram or UDP socket would do. The bash script would just send a datagram to that socket (you may need a helper program that does
sendmsg()orsendto()on that socket, such as socat or netcat/nc). The receiver does not need to accept connections for datagram sockets, once it is ready for read there must be a datagram waiting. Subject to datagram length restrictions.