title: How do I wait for sub-process to complete in Linux
body: <p>I need to play a wave file using <code>aplay</code>. However, my wave files are few seconds in length. So I plan to play them in loop for certain period of time. <code>aplay</code> does not seem to have loop options.  From my C file create a sub-process using <code>popen()</code>  The playback is working fine. But the difficulty is that I can't monitor when the wave file playback is completed so that I can start over. </p>
  
  <pre><code>popen("aplay WaveFile","r");
  </code></pre>
  
  <p>How do I know when this command has finished playback?</p>
  
  <p>Thanks in advance!</p>