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

Is this a deadlock waiting to happen?



Ray wrote:

    body_list=( ${(@f)"$( highlight $filename )"} ) 2>&1 | read _err

I was surprised to find that both $body_list and $_err are set in the
current shell.  I had presumed that piping to read would cause the left
side to be forked and the right to be executed in the current shell.

And indeed if I change this to:

    body_list=( ${(@f)"$( highlight $filename )"} ) : 2>&1 | read _err

then both the assignment and the ":" command are forked off and only
$_err is available to the current shell.

In the former situation, is it not the case that if the output to stderr
is too large for the OS to buffer in the pipeline, zsh is going to be
deadlocked, because [in the example] "highlight" will be blocked writing
to stderr while zsh is blocked waiting to read stdout from $(...) ?

Where did we optimize out the fork?



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