zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: coproc fd leak leading to possible deadlock
Date: Thu, 07 Mar 2013 08:58:30 -0800	[thread overview]
Message-ID: <130307085830.ZM12345@torch.brasslantern.com> (raw)
In-Reply-To: <20130306225341.GA12150@chaz.gmail.com>

On Mar 6, 10:53pm, Stephane Chazelas wrote:
: Subject: coproc fd leak leading to possible deadlock
:
: When we run an external command as a coproc, all is fine, but if
: we run a subshell, that subshell ends up having open fds for
: both ends of both pipes, leading to potential deadlocks

Yes, I've been pointing out problems with coproc descriptor handling
for a while now (search zsh-worker mailing list archives).  So far I
have not found any issues with zsh's descriptor handling that are not
also shared by at least bash if not also ksh, so there hasn't been any
effort put into fixing things for a while.

: ~$ exec zsh -f
: sc% coproc {sleep 100; sleep 100}

The workaround for this one is to run a dummy coprocess *inside* the
coprocess:

% coproc { coproc : ; sleep 100; sleep 100 }

This should force closed the descriptors in the subshell that were
inherited from the parent shell, leaving the stdin/stdout connected to
the original pipes.

There's some discussion of why this happens (and why it's convoluted
to detect the situation) in the archives.  The short answer is that the
descriptors are close-on-exec [which is why "coproc sh ..." works] but
there's no exec with a subshell.


      parent reply	other threads:[~2013-03-07 16:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06 22:53 Stephane Chazelas
2013-03-07  6:28 ` Han Pingtian
2013-03-07 16:58 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=130307085830.ZM12345@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).