title: run a background terminal process in python loop one by one
body: <p>I want to execute this command in terminal shell using python:</p>
  <p>command= <code>'program.x input.in output.out &amp;'</code></p>
  <p>I need to keep updating the input files with different parameters so I am using a python for loop to do so.</p>
  <p>My code looks something like this:</p>
  <pre><code>for i in range ():
      *code to update input file here*
  
      os.system(command)
  </code></pre>
  <p>What I want to do is in every loop, I want to let the os.system process finish first before moving to the next loop. But When I try my code, the python runs the loop all at once, and I have like 10 different <code>command</code> processes running in the background of my system. Is there any way I can run these processes in background while running the loop one by one until a process is finished?</p>
  <p>When I remove that ' &amp;' sign from the command, the code works well so it is only an issue with background processes.</p>