From: Dima Kogan <dima@secretsauce.net>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers <zsh-workers@zsh.org>
Subject: Re: Possible bug in signal handling
Date: Tue, 03 Nov 2015 20:27:00 -0800 [thread overview]
Message-ID: <87vb9ifkyz.fsf@secretsauce.net> (raw)
In-Reply-To: <151103201631.ZM19473@torch.brasslantern.com>
Bart Schaefer <schaefer@brasslantern.com> writes:
> On Nov 2, 2:10am, Dima Kogan wrote:
> }
> } I have a /tmp/tst.sh script:
> }
> } awk '{print; fflush()}' | \
> } perl -e 'BEGIN { $SIG{INT} = sub { $SIG{INT} = undef; }; } while(<>) {sleep 1;} sleep 10000;'
> }
> } I invoke this script thusly:
> }
> } $ seq 5000 | perl -nE 'say "xxx"; sleep(1)' | zsh /tmp/tst.sh
> }
> } So it's a mostly do-nothing pipeline. When the user hits Ctrl-C the
> } first time, I expect everything but the inner zsh and the inner perl
> } processes to die, and the outer zsh to NOT display another prompt until
> } a second Ctrl-C. Instead I see everything except the inner perl die
> } (inner zsh dies too), and the prompt is returned immediately.
>
> I'm able to get bash to orphan that perl process sometimes, too, just
> not reliably.
>
> The difference seems to be that bash calls waitpid() whereas zsh uses
> sigpause() and doesn't do the wait*() until the SIGCHLD arrives. The
> order of arrival of the CHLD and INT signals may therefore determine
> whether the shell continues waiting or not.
>
> Changing the script to this --
>
> trap '' INT
> { trap - INT; awk '{print; fflush()}'; } | \
> perl -e 'BEGIN { $g = getpgrp($$); print "$g\n"; $SIG{INT} = sub {
> $SIG{INT} = undef; }; } while(<>)
> {sleep 1;} sleep 10000;'
>
> -- gets both shells to wait for perl to exit before the script exits.
Thanks for looking at this, Bart. I don't really understand this area in
detail, but should those changes be necessary? Is it not a bug in zsh
(and bash, I guess) that the perl process is orphaned?
next prev parent reply other threads:[~2015-11-04 4:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 10:10 Dima Kogan
2015-11-04 4:16 ` Bart Schaefer
2015-11-04 4:27 ` Dima Kogan [this message]
2015-11-04 4:46 ` Bart Schaefer
2015-11-04 14:25 ` Vincent Lefevre
2015-11-04 19:01 ` Bart Schaefer
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=87vb9ifkyz.fsf@secretsauce.net \
--to=dima@secretsauce.net \
--cc=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).