bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: backgrounded children forgotten


From: Sven Wegener
Subject: Re: backgrounded children forgotten
Date: Sun, 11 Dec 2005 12:56:52 +0100
User-agent: Mutt/1.5.11

On Sat, Dec 10, 2005 at 11:36:36PM -0500, Aron Griffis wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: x86_64-pc-linux-gnu-gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib   -march=nocona -O3 -pipe 
> -fomit-frame-pointer
> uname output: Linux vino 2.6.15-rc1 #1 SMP PREEMPT Thu Nov 17 10:10:29 EST 
> 2005 x86_64 Intel(R) Xeon(TM) CPU 3.20GHz GenuineIntel GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
> 
> Bash Version: 3.0
> Patch Level: 16
> Release Status: release
> 
> Description: 
>       When 2 processes are backgrounded inside $(...), bash forgets the first 
>       one was a child of the shell.
> 
> Repeat-By:
>       Note this needs to be a script, not cmdline, otherwise $! doesn't work.
> 
>       $ cat demo
>       output=$( 
>           true &
>           pid=$!
>           true &
>           sleep 1
>           wait $pid
>       )
> 
>       $ bash demo
>       demo: line 13: wait: pid 25183 is not a child of this shell

Hi Aron! Hi list!

To me it looks like, that you can only wait for child processes that are
still running. The backgrounded true will exit nearly immediately and
wait can't wait for it because it has already terminated.

Looking at the source it proves me right for wait without any arguments.
"But wait without any arguments means to wait for all of the shell's
currently active background processes." And I guess that for wait <pid>
the process still needs to be running. Replacing true in your example
with e.g. sleep 10 makes wait <pid> work.

Sven

-- 
Sven Wegener
Gentoo Developer
http://www.gentoo.org/

Attachment: pgpzHxlRJgptD.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]