In the code below we wait
for a background process twice. In the first paragraph we get the expected 0 return code from the wait. In the second paragraph the only change is wrapping the wait in a command substitution which instead gives a 255 return code. Why is this?
sleep 1 &
wait $!
echo $? # prints "0"
sleep 1 &
a=$(wait $!) # <---- only difference is cmd substitution
echo $? # prints "255"
Thanks in advance for your thoughts!
You must log in or register to comment.