Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15877 > unrolled thread

Re: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'

Started byHarald van Dijk <harald@gigawatt.nl>
First post2020-02-08 18:39 +0000
Last post2020-02-08 18:39 +0000
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait' Harald van Dijk <harald@gigawatt.nl> - 2020-02-08 18:39 +0000

#15877 — Re: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'

FromHarald van Dijk <harald@gigawatt.nl>
Date2020-02-08 18:39 +0000
SubjectRe: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'
Message-ID<mailman.512.1581187279.2412.bug-bash@gnu.org>
On 07/02/2020 02:41, Robert Elz wrote:
>      Date:        Thu, 6 Feb 2020 16:12:06 +0000
>      From:        Martijn Dekker <martijn@inlv.org>
>      Message-ID:  <10e3756b-5e8f-ba00-df0d-b36c93fa2281@inlv.org>
> 
>    | NetBSD sh behaves differently. NetBSD 8.1 sh (as installed on sdf.org
>    | and sdf-eu.org) seem to act completely normally, but NetBSD 9.0rc2 sh
>    | (on my VirtualBox test VM) segfaults. Output on NetBSD 9.0rc2:
> 
> I have updated my opinion on that, I think it is "don't have the bug",
> though it is possible a blocked SIGCHLD acts differently on NetBSD than
> on other systems.   On NetBSD it seems to affect nothing (the shell does
> not rely upon receiving SIGCHLD so not getting it is irrelevant) and
> the wait code when given an arg (as your script did) would always wait
> until that process exited, and return as soon as it did.

I think you're right that this isn't SIGCHLD behaving differently on 
NetBSD, it's that NetBSD sh does not have the same problem the other 
ash-based shells do. The problem is with sigsuspend, which in dash looks 
like:

> 		sigblockall(&oldmask);
> 
> 		while (!gotsigchld && !pending_sig)
> 			sigsuspend(&oldmask);
> 
> 		sigclearmask();

<https://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/jobs.c?id=f30bd155ccbc3f084bbf03d56f9cc43f4b02af2a#n1170>

This clearly cannot work when oldmask blocks SIGCHLD.

NetBSD sh does not use sigsuspend here, so avoids that problem.

I changed gwsh to call sigclearmask() on shell startup, but plan to 
check whether this loop is really necessary at some later time. It was 
added to dash to fix a race condition, where that race condition was 
apparently introduced by a fix for another race condition. If NetBSD sh 
manages to avoid this pattern, and assuming NetBSD sh is not still 
susceptible to one of those race conditions, the fix for it in the other 
shells would seem to be more complicated than necessary, and simplifying 
things would be good.

Cheers,
Harald van Dijk

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web