Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible bug in signal handling
- X-seq: zsh-workers 37059
- From: Dima Kogan <dima@xxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Possible bug in signal handling
- Date: Tue, 03 Nov 2015 20:27:00 -0800
- Cc: zsh-workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=dP6hK b2dhKF4kWleFnNBzLwACg4=; b=Hm4OePCsTXHD3tlUNU9GyJkd8tF3d3vVLYo12 hRTAtYtHBIBaFoEt8vheqVrjDuEI1UJPU+xpIaGMjLMV3Vd4r/QteHi6+wepFYnH 3EzgZdL6QKrZFmRkU5Hu6uZiJGegkp/ShER2XJLesZ9neerGd87VX8UNX/yIy5qd 9p9wT4=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=dP6hKb2dhKF4kWleFnNBzLwACg4=; b=pqv6U YrpbdqGhyLVD4Ua+amiwlePIfgsYDhn13LjdaHj/O4MuKOaR4U/+0bggdjG09V6O q7SuaoVkBx/lRgeHKmTehRKSIWsRorbXMOEM3G4fa+8GLS6xPJJ49cwABhPOjAao VrSH7sGkaJ5VP+aQuvx38IDOU6yx7FBHxLUZHM=
- In-reply-to: <151103201631.ZM19473@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <87wpu0g19r.fsf@secretsauce.net> <151103201631.ZM19473@torch.brasslantern.com>
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author