zsh-workers
 help / color / mirror / code / Atom feed
* Is this a deadlock waiting to happen?
@ 2015-11-14 22:47 Bart Schaefer
  2015-11-15 17:36 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2015-11-14 22:47 UTC (permalink / raw)
  To: zsh-workers

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?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is this a deadlock waiting to happen?
  2015-11-14 22:47 Is this a deadlock waiting to happen? Bart Schaefer
@ 2015-11-15 17:36 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2015-11-15 17:36 UTC (permalink / raw)
  To: zsh-workers


On 14 Nov 2015 22:47, Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> 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.

There is a very longstanding set of cases where the fork happens in execcmd()  rather than up in execpline(), at the point where it would fork before an exec. I presume this is one of those. Then prefork()  substitutions are done first. I don't have the code with me but I think it's fairly tortuous (surprise).

pws

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-15 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-14 22:47 Is this a deadlock waiting to happen? Bart Schaefer
2015-11-15 17:36 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).