linuxpersistentfifomkfifo

how to use a persistent named pipe under linux?


Use named pipe some times very convenient, such as mkfifo file.fifo.

but the file.fifo is not persistent, if the computer restarted or the writer process crashed, I can get nothing from the pipe. so, are there any methods to let the piped data store in disk rather than memory?

thanks.


Solution

  • The simplest solution is to use plain files to store the data. For example, and use a pipe (or similar) to notify that there are new data, for example. You must take care of interprocess locking, of course.

    Or you can use "message queues" (see mqueue.h). They are persistent in case of process crash, but not if the system is rebooted.

    Or you can use a third-party library that implements "persistent message queues", such as MQTT or RabbitMQ.