Hi Sven, Sven Wegener wrote: [Sun Dec 11 2005, 06:56:52AM EST] > 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.
I agree that the child needs to have already exited to demonstrate the
bug, that's why I had the sleep in there. Here is a clarification:
- This version works. The exit status of the first subshell is
harvested by the call to wait.
$ cat demo-good
#!/bin/bash
( exit 10 ) &
pid=$!
true &
sleep 1
wait $pid
echo $? >&2
$ ./demo-good
10
- This version breaks because it is inside command substitution. The
exit status is lost and the error message is emitted.
$ cat demo-bad
#!/bin/bash
output=$(
( exit 10 ) &
pid=$!
true &
sleep 1
wait $pid
echo $? >&2
)
$ ./demo-bad
./demo-bad: line 14: wait: pid 4046 is not a child of this shell
127
Regards,
Aron
--
Aron Griffis
Gentoo Linux Developer
pgpSdINqc02XI.pgp
Description: PGP signature
_______________________________________________ Bug-bash mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-bash
