Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: 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../bash -I../bash/include
-I../bash/lib -g -O2 -Wall
uname output: Linux zorba 2.6.28-16-generic #57-Ubuntu SMP Wed Nov 11
09:49:32 UTC 2009 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 3.2
Patch Level: 48
Release Status: release
Description:
It probably never makes sense to background the "wait" builtin, but
if one makes this error, the
resulting error message is nonsensical and confusing:
wait: pid nnnnn is not a child of this shell ## (where nnnnn is the pid)
Repeat-By:
E.g.:
#!/bin/bash
stdinFile=/tmp/stdin.$$
echo "echo \"here we are!\" ; sleep 3 ;" > $stdinFile
bashCommand=`cat $stdinFile`
/bin/bash -s <$stdinFile & ## it doesn't matter which
# /bin/bash -c "$bashCommand" & ## of these two lines is uncommented
pidOfBackgroundProcess=$! ;
echo "pidOfBackgroundProcess=$pidOfBackgroundProcess" ;
wait $pidOfBackgroundProcess & ## the ampersand here is the error that
triggers the nonsensical error message
The typescript of an actual run of the above script looked like this:
r...@zorba:/home/srn# /tmp/z.sh
here we are!
pidOfBackgroundProcess=20944
/tmp/z.sh: line 10: wait: pid 20944 is not a child of this shell
(But, of course, pid 20944 *was* in fact a child of this shell.)
Fix:
Never background an invocation of the wait builtin, accidentally
or otherwise.
(Unfortunately, I'm not always alert enough to avoid doing this,
and I suspect there
are others like me.)
Steve Newcomb
s...@coolheads.com
+1 910 363 4032