title: Linux C process wait till copy of files completed (shell command)
body: <p>I am trying to copy multiple folders and files from one folder (linux SBC) to another folder (USB mounted folder) from a process.</p>
  
  <p>My process is completely written in C. The linux system is an SBC running YOCTO, and it doesnt have <code>rsync</code> available.</p>
  
  <p>I used <code>popen</code> command for most of the commands like <code>mount</code>, <code>umount</code>, etc..
  But for copying (<code>cp</code> command) I am not sure how to wait for the copy to complete.</p>
  
  <p>I am using below format in my C code and it works (copying works)</p>
  
  <pre><code>system("yes | cp -rf " USB_DATA_SOURCE_PATH " " USB_DATA_DESTINATION_PATH);
  </code></pre>
  
  <p>I need to copy multiple files and there can be any number of files with dynamic names. All I need is a way to know that the copying is completed and is safe to <code>umount</code> and indicate to the user.</p>