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


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

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

Started byHarald van Dijk <harald@gigawatt.nl>
First post2020-02-06 19:29 +0000
Last post2020-02-06 19:29 +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-06 19:29 +0000

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

FromHarald van Dijk <harald@gigawatt.nl>
Date2020-02-06 19:29 +0000
SubjectRe: Bizarre interaction bug involving bash w/ lastpipe + Almquist 'wait'
Message-ID<mailman.390.1581022060.2412.bug-bash@gnu.org>
On 06/02/2020 16:12, Martijn Dekker wrote:
> This is probably the strangest bug (or maybe pair of bugs) I've run into 
> in nearly five years of breaking shells by developing modernish.
> 
> I've traced it to an interaction between bash >= 4.2 (i.e.: bash with 
> shopt -s lastpipe) and variants of the Almquist shell, at least: dash, 
> gwsh, Busybox ash, FreeBSD sh, and NetBSD 9.0rc2 sh.
> 
> Symptom: if 'return' is invoked on bash in the last element of a pipe 
> executed in the main shell environment, then if you subsequently 'exec' 
> an Almquist shell variant so that it has the same PID, its 'wait' 
> builtin breaks.
> 
> I can consistently reproduce this on Linux, macOS, FreeBSD, NetBSD 
> 9.0rc2, OpenBSD, and Solaris.
> 
> To reproduce this, you need bash >= 4.2, some Almquist shell variant, 
> and these two test scripts:
> 
> ---begin test.bash---
> fn() {
>      : | return
> }
> shopt -s lastpipe || exit
> fn
> exec "${1:-dash}" test.ash
> ---end test.bash---
> 
> ---begin test.ash---
> echo '*ash-begin'
> : &
> echo '*ash-middle'
> wait "$!"
> echo '*ash-end'
> ---end test.ash---
> 
> When executing test.bash with dash, gwsh, Busybox ash, or FreeBSD sh, 
> then test.ash simply waits forever on executing 'wait "$!"'.

Nice test. bash leaves the process in a state where SIGCHLD is blocked, 
and the various ash-based shells do not unblock it. Because of that, 
they do not pick up on the fact that the child process has terminated. I 
would consider this a bug both in bash and in the ash-based shells.

Cheers,
Harald van Dijk

[toc] | [standalone]


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


csiph-web