DASH Shell discussions
 help / color / mirror / Atom feed
From: Jilles Tjoelker <jilles@stack.nl>
To: dash@vger.kernel.org
Subject: Re: wait regression in 3800d4
Date: Sat, 22 May 2010 23:28:52 +0200	[thread overview]
Message-ID: <20100522212852.GA36029@stack.nl> (raw)
In-Reply-To: <20100519190856.19606.qmail@ea7dd6dfa89c0a.315fe32.mid.smarden.org>

On Wed, May 19, 2010 at 07:08:56PM +0000, Gerrit Pape wrote:
> Hi, since commit 3800d49 the wait builtin shows some unexpected
> behavior, see http://bugs.debian.org/581425

> To reproduce:

>  $ dash -c '
>  for i in 1 2 3; do
>    (sleep $i; echo $i) &
>  done
>  wait
>  echo all done
>  sleep 2'
>  1
>  all done
>  2
>  3
>  $ 

> Expected output:
>  1
>  2
>  3
>  all done

> I don't completely understand commitdiff 3800d49, and didn't find time
> to fix the lack of understanding yet, but this patch seems to fix this
> specific issue.

> diff --git a/src/jobs.c b/src/jobs.c
> index a4fada0..57c0854 100644
> --- a/src/jobs.c
> +++ b/src/jobs.c
> @@ -1136,8 +1136,6 @@ waitproc(int block, int *status)
>                 if (err || !block)
>                         break;
>  
> -               block = 0;
> -
>                 sigfillset(&mask);
>                 sigprocmask(SIG_SETMASK, &mask, &oldmask);
>  

This patch is not correct as it makes dash busy-wait for the second and
further processes to terminate. Also, I think aborting the wait builtin
with 128+SIGCHLD is the correct behaviour if a trap on CHLD is active
(like any other trap). This requires a more sophisticated handling of
pendingsigs so that an untrapped SIGCHLD does not overwrite a trapped
signal.

I wonder why this hasn't been noticed before, as this is the most common
use of the wait builtin. I can even reproduce the regression with the
test script in 3800d49's commit message: sometimes I see a line *** 148
meaning that the wait builtin was aborted by SIGCHLD (even though no
CHLD trap has been set); however only on an SMP system. (This is on
FreeBSD; I hacked mksignames.c to compile and work, although realtime
signals are missing.)

-- 
Jilles Tjoelker

  reply	other threads:[~2010-05-22 21:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19 19:08 wait regression in 3800d4 Gerrit Pape
2010-05-22 21:28 ` Jilles Tjoelker [this message]
2010-05-27 11:39   ` Herbert Xu

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=20100522212852.GA36029@stack.nl \
    --to=jilles@stack.nl \
    --cc=dash@vger.kernel.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox