> If I have shell script which has a command that runs in the background, is it > possible to get its return code.
Use wait:
$ sh -c 'false & wait $!; echo $?' 1 $ sh -c 'true & wait $!; echo $?' 0
$ echo aa bb cc dd & wait $! ; echo $? aa bb cc dd [1] 13529 [1]+ Done echo aa bb cc dd 0
Ref:
$ echo aa bb cc dd & ; wait $! ; echo $? bash: syntax error near unexpected token `;'
documented on: 22:16:19