title: How can I launch a new process that is NOT a child of the original process?
body: <p>(OSX 10.7) An application we use let us assign scripts to be called when certain activities occur within the application.  I have assigned a bash script and it's being called, the problem is that what I need to do is to execute a few commands, wait 30 seconds, and then execute some more commands.  If I have my bash script do a "sleep 30" the entire application freezes for that 30 seconds while waiting for my script to finish.</p>
  
  <p>I tried putting the 30 second wait (and the second set of commands) into a separate script and calling "./secondScript &amp;" but the application still sits there for 30 seconds doing nothing.  I assume the application is waiting for the script <em>and all child processes</em> to terminate.</p>
  
  <p>I've tried these variations for calling the second script from within the main script, they all have the same problem:</p>
  
  <ul>
  <li>nohup ./secondScript &amp;</li>
  <li>( ( ./secondScript &amp; ) &amp; )</li>
  <li>( ./secondScript &amp; )</li>
  <li>nohup script -q /dev/null secondScript &amp;</li>
  </ul>
  
  <p>I do not have the ability to change the application and tell it to launch my script and not wait for it to complete.</p>
  
  <p>How can I launch a process (I would prefer the process to be in a scripting language) such that the new process is not a child of the current process?</p>
  
  <p>Thanks,
  Chris</p>
  
  <p>p.s. I tried the "disown" command and it didn't help either.  My main script looks like this:</p>
  
  <pre><code>[initial commands]
  echo Launching second script
  ./secondScript &amp;
  echo Looking for jobs
  jobs
  echo Sleeping for 1 second
  sleep 1
  echo Calling disown
  disown
  echo Looking again for jobs
  jobs
  echo Main script complete
  </code></pre>
  
  <p>and what I get for output is this:</p>
  
  <pre><code>Launching second script
  Looking for jobs
  [1]+ Running ./secondScript &amp;
  Sleeping for 1 second
  Calling disown
  Looking again for jobs
  Main script complete
  </code></pre>
  
  <p>and at this point the calling application sits there for 45 seconds, waiting for secondScript to finish.</p>
  
  <p>p.p.s</p>
  
  <p>If, at the top of the main script, I execute "ps" the only thing it returns is the process ID of the interactive bash session I have open in a separate terminal window.</p>
  
  <p>The value of $SHELL is /bin/bash</p>
  
  <p>If I execute "ps -p $$" it correctly tells me</p>
  
  <pre><code>PID   TTY TIME    CMD
  26884 ??  0:00.00 mainScript
  </code></pre>
  
  <p>If I execute "lsof -p $$" it gives me all kinds of results (I didn't paste all the columns here assuming they aren't relevant):</p>
  
  <pre><code>FD   TYPE   NAME
  cwd  DIR    /private/tmp/blahblahblah
  txt  REG    /bin/bash
  txt  REG    /usr/lib/dyld
  txt  REG    /private/var/db/dyld/dyld_shared_cache_x86_64
  0    PIPE   
  1    PIPE   -&gt; 0xffff8041ea2d10
  2    PIPE   -&gt; 0xffff 8017d21cb
  3r   DIR    /private/tmp/blahblah
  4r   REG    /Volumes/DATA/blahblah
  255r REG    /Volumes/DATA/blahblah
  </code></pre>