I want to output some data to a pipe and have the other process do something to the data line by line. Here is a toy example:
mkfifo pipe
cat pipe&
cat &
As an alternative to the other solutions here, you can call cat
in a loop as the input to your command:
mkfifo pipe
(while true ; do cat pipe ; done) | bash
Now you can feed it commands one at a time and it won't close:
echo "'echo hi'" > pipe
echo "'echo bye'" > pipe
You'll have to kill the process when you want it gone, of course. I think this is the most convenient solution since it lets you specify the non-exiting behavior as you create the process.