Skip to main content
added 311 characters in body
Source Link
Ole Tange
  • 37.6k
  • 34
  • 120
  • 230

By only opening PIPEIN for writing once, the program terminates - even if there is a 2 second delay:

mkfifo PIPEIN PIPEOUT tr 'a-z' 'A-Z' < PIPEIN > PIPEOUT & # for example tail -n +1 -f PIPEOUT & ( for i in a b c d ; do echo $i done sleep 2 echo "[stdin end]" ) > PIPEIN 

If you open the fifo several times, then it may be seen as closed by the reader of the fifo, and thus the writer will be hung until another reader comes along to read from the fifo.

So the save bet is to only open PIPEIN once. Otherwise you may see that the program locks up.

By only opening PIPEIN for writing once, the program terminates - even if there is a 2 second delay:

tr 'a-z' 'A-Z' < PIPEIN > PIPEOUT & # for example tail -n +1 -f PIPEOUT & ( for i in a b c d ; do echo $i done sleep 2 echo "[stdin end]" ) > PIPEIN 

By only opening PIPEIN for writing once, the program terminates - even if there is a 2 second delay:

mkfifo PIPEIN PIPEOUT tr 'a-z' 'A-Z' < PIPEIN > PIPEOUT & # for example tail -n +1 -f PIPEOUT & ( for i in a b c d ; do echo $i done sleep 2 echo "[stdin end]" ) > PIPEIN 

If you open the fifo several times, then it may be seen as closed by the reader of the fifo, and thus the writer will be hung until another reader comes along to read from the fifo.

So the save bet is to only open PIPEIN once. Otherwise you may see that the program locks up.

Source Link
Ole Tange
  • 37.6k
  • 34
  • 120
  • 230

By only opening PIPEIN for writing once, the program terminates - even if there is a 2 second delay:

tr 'a-z' 'A-Z' < PIPEIN > PIPEOUT & # for example tail -n +1 -f PIPEOUT & ( for i in a b c d ; do echo $i done sleep 2 echo "[stdin end]" ) > PIPEIN