In bash, I would like to run a background process, do something in loop while the process is running, and once the process stopped I would like to get its return code.
Here is what I have so far:
my_build_command
build_pid=$!
sleep 1
while [[ -d /proc/$build_pid ]]
do
# Do something...
sleep 1
done
# HOW TO GET THE RETURN CODE OF build_pid?
Is it possible to achieve what I want?