In C pseudo-code:
while (1) {
fifo = open("fifo", O_RDONLY | O_NONBLOCK);
fd_set read;
FD_SET(fifo, &read);
select(nfds, &read, NULL, NULL, NULL);
}
The process sleeps as triggered by select()
until another process writes into fifo
. Afterwards it will always find fifo
as a readable file descriptor.
How to avoid this behavior (that is, after fifo
has been read once, how to make it be found as unreadable until it gets another write?)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…