bg_job&
pid=$!
wait $pid
if [ $pid -eq {whatever value you expected} ]
then
echo "success"
else
echo "bg_job return code is: $?"
fi
WAIT EXIT STATUS
If one or more operands were specified, all of them have
terminated or were not known by the invoking shell, and the
status of the last operand specified is known, then the exit
status of wait will be the exit status information of the
command indicated by the last operand specified. If the
process terminated abnormally due to the receipt of a sig-
nal, the exit status will be greater than 128 and will be
distinct from the exit status generated by other signals,
but the exact value is unspecified. (See the kill -l
option.) Otherwise, the wait utility will exit with one of
the following values:
0 The wait utility was invoked with no operands and
all process IDs known by the invoking shell have
terminated.
1-126
The wait utility detected an error.
127 The command identified by the last pid operand
specified is unknown.