Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有时使用命名管道非常方便,例如mkfifo file.fifo.
mkfifo file.fifo
但是 file.fifo 不是持久的,如果计算机重新启动或编写器进程崩溃,我无法从管道中得到任何信息。那么,有什么方法可以让管道数据存储在磁盘而不是内存中?
谢谢。
最简单的解决方案是使用普通文件来存储数据。例如,并使用管道(或类似的)来通知有新数据,例如。当然,您必须注意进程间锁定。
或者您可以使用“消息队列”(参见mqueue.h)。它们在进程崩溃的情况下是持久的,但如果系统重新启动则不会。
或者您可以使用实现“持久消息队列”的第三方库,例如MQTT或RabbitMQ。