Linux: timeout when opening a named pipe for writing

I have one process writing to another through a named pipe. It is possible that the reading process will be incorrect and will not open the pipe for reading. If this happens, my write process with good behavior will freeze when it is called open (). I want the writer to be able to timeout when opening the pipe, so that he can clear himself and continue to work if the reader does not have time to open his time. Non-blocking open () immediately returns an error.

+4
source share
2 answers

If this is an option, use unix domain sockets for a script like this. Because of the semantics of FIFO, this is an awkward way to do this, and you are likely to run into problems anyway. And this design will not scale outside of one client if it becomes necessary. In the short term, you can secure your will in FIFO, but I suspect you will regret it.

Outlets are more natural for this. Your auditory socket fits perfectly into your existing survey (), the client connects, the writer discards his data, both end the disconnection, and everyone is happy. No fuss, no mousse.

+3
source

In your recording process, open the channel in read-write mode, which should prevent it from hanging :)

0
source

Source: https://habr.com/ru/post/1400304/


All Articles