On Mon, 9 Feb 2004, Andrew Pimlott wrote:
However, when using pipes, the exitcode of only one of the involved processes can be monitored.
Let me give my frank opinion that, even though it's how shell scripts have always worked, this should be considered broken.
Well, HsUnix is somewhat better, since one process can be monitored.
It is rather a pain to fix, as you can't implement it in the usual straightforward way. You have to fork all subprocesses from the main process, and do extra work to share the pipes. If you don't want to use filehandles extravagantly, you have to do additional work. I essentially wrote a mini-OS layer that wraps all fork, pipe, and open calls, and tries (in a fairly dumb but usually effective way) to allocate filehandles efficiently. I can share if you'd like. (I found this exercise gave great insight into the "worse is better" philosophy.)
I wonder if this could be incorporated in hsunix. I'd like to take a look at your implementation.
If you don't change this behavior, at least document it prominently as a robustness sink! :-)
I've added it to the documentation. Regards, Volker