title: Bash - running process in background and getting return code after it's done
body: <p>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.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>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?
  </code></pre>
  
  <p>Is it possible to achieve what I want?</p>