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

Re: More tests

Peter Stephenson wrote:
>2. There's something wrong with synchronisation in multios:
>% print hello >foo >bar && print "$(<foo)"

What happens here is that stdout for the first print is a pipe to a
process doing what amounts to a tee.  After the print, that pipe gets
closed, the tee process notices this and exits, after it's written all
the pending data to its outputs.  However, this is fundamentally done
asynchronously.  Closing the tee's input does not immediately force
the tee to complete.  Quite feasibly, the print could send its output
and close tee's input and then the empty foo gets read, all in a single
timeslice, before tee has had a chance to look at its input.

To fix this, closing the redirected fd would have to also wait for the
tee process to exit.  This should be doable by storing pids in the save
array and waiting in fixfds().  There's also the subtlety of nested tees
to handle.  Might be easier just to save all the necessary pids in a
single linked list, separately from the saved fd information; we don't
really need to correlate them.

There's a similar issue with input multios.  The closing of the multio fd
should guarantee that all the input files have been closed.  This could
be done most easily by directly killing the cat process (at this point,
we *want* to lose any data it has buffered).


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