title: Get exit code of a background process
body: <p>I have a command CMD called from my main bourne shell script that takes forever.</p>
  <p>I want to modify the script as follows:</p>
  <ol>
  <li>Run the command CMD in parallel as a background process (<code>CMD &amp;</code>).</li>
  <li>In the main script, have a loop to monitor the spawned command every few seconds. The loop also echoes some messages to stdout indicating progress of the script.</li>
  <li>Exit the loop when the spawned command terminates.</li>
  <li>Capture and report the exit code of the spawned process.</li>
  </ol>
  <p>Can someone give me pointers to accomplish this?</p>