Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

named pipes blocking zsh


I have a situtation with zsh: I use pine as my mail reader and it has a feature where it can create a named pipe (FIFO) and write to it when new mail arrives. Naturally, I thought of writing a script at the other end of the pipe that reads the messages and sends me notifications in some other way.

The way I have it set up is to have a zsh script that starts another "notify" child zsh script that reads from the pipe and does its notification thing and then the main script calls pine.

This all seems to work, except when I quit pine, hence terminating the main "parent" script, the child "notify" script does not exit, it's stuck reading from the pipe (even though the pipe is deleted). The child script becomes owned by PPID 1 and the only way to kill it is kill -9 ...

I'm reading with the built in "read var < pine_pipe" which blocks until the first line of data is written to the pipe by pine. I also tried "read -t" but it doesn't react to the timeout. Also tried the zselect module, with and without timeouts, nothing works. If there's nothing in the pipe, the zsh process just hangs until there is data.

My current workaround is to trap the exits from the main script and kill -9 the child script. This works fine almost all the time except when the main script itself is killed and it doesn't have a chance to kill it's child. For this I made the notify script clean up any running instances of itself when it comes up (but there's still that window of time where there's a zsh process around that refuses to die).

Is there anything in particular I should be aware of with these named pipes? I'm using zsh 4.2.1 if it makes a difference ...

Thanks for your help.


Messages sorted by: Reverse Date, Date, Thread, Author