Two windows, same user, with bash prompts. In window-1 type:
$ mkfifo f; exec <f
So bash is now attempting to read from file descriptor 0, which is mapped to named pipe
f. In window-2 type:
$ echo ls > f
Now window-1 prints an ls and then the shell dies. Why?
Next experiment: open window-1 again with
exec <f. In window-2 type:
$ exec 3>f $ echo ls >&3
After the first line above, window-1 wakes up and prints a prompt. Why? After the second line above, window-1 prints the
ls output and the shell stays alive. Why? In fact, now in window-2,
echo ls > f does not close the window-1 shell.
The answer must have to do with the existence of the file descriptor 3 from window-2 referencing the named pipe?!