title: Running bash script from ruby not producing the correct pid
body: <p>I am developing a ruby framework to run different jobs and one of the things that I need to do is to know when these jobs have ended in order to used their outputs and organize everything. I have been using it with no problem but some colegues are starting to use it in different system and something really odd is happening. What I do is run the commands using </p>
  
  <pre><code>i,o,e,t = Open3.popen3(job.get_cmd)
  p = t.pid
  </code></pre>
  
  <p>and later I check if the job has ended like this:</p>
  
  <pre><code>begin
     Process.getpgid(p)
  rescue Errno::ESRCH
     # The process ended
  end
  </code></pre>
  
  <p>It works perfectly in the system I am running (Scientifi linux 6) but when a friend of mine started running on Ubuntu 14.04 (using ruby 1.9.3p484) and the command is a concatenation of commands such as <code>cmd1 &amp;&amp; cmd2 &amp;&amp; cmd3</code> each command is run at the same time by the system, not one after the other, and the pid returned by <code>t.pid</code> is neither of the pids of the different processes being run.</p>
  
  <p>I modified the code and instead of running the concatenation of cammands it creates a script with all the command inside the command called from popen3 is just <code>Open3.popen3("./script.sh")</code> but the behaviour is the same... All the commands are run at the same time and the pid that ruby knows is not any of the processes pid...</p>
  
  <p>I am not sure if this is something ruby related but since running that <code>script.sh</code> by hand behaves as expected, running one command after the other, it seems that either ruby is not launching the process accordingly or the system is not reading the process as it should. Do you know what might be happening?</p>
  
  <p>Thanks a lot!</p>
  
  <p>EDIT:
  The command being run looks like this
  <code>./myFit.exe h vlq.config  &amp;&gt; output_h.txt &amp;&amp; ./myFit.exe d vlq.config  &amp;&gt; output_d.txt &amp;&amp; ./myFit.exe p vlq.config  &amp;&gt; output_p.txt</code></p>
  
  <p>This command, if run by hand and not inside the ruby script runs perfectly, exactly this command. When run from the ruby script it runs at the same time all the myFit.exe executions (but I want them to be run withh &amp;&amp; becasue I want them running if the previous works fine). Myfit.exe is a tool which makes a fit, is not a system command. Again, this command, if run by hand runs perfeclty.</p>