title: Background spawned process in Expect
body: <p>I'm using expect to start an application on my server:</p>
  
  <pre><code>#!/usr/bin/expect
  
  set timeout -1
  
  spawn "bin/start-all.sh"
  expect {
      -re "Found MongoDB in" { send "y\r"; exp_continue }
      -re "Found Hadoop in" { send "y\r"; exp_continue }
      -re "Going to start Hadoop" { interact }
  }
  </code></pre>
  
  <p>I can access the application on my server in the few seconds while the script is running, but as soon as it ends the application becomes unavailable.</p>
  
  <p>I've run expect in debug mode and get the following output towards the end:</p>
  
  <pre><code>expect: does "vendors area. Do you want to start it? [y/n] y\r\n" (spawn_id exp6) match regular expression "Found MongoDB in"? Gate "Found MongoDB in"? gate=no
  "Found Hadoop in "? Gate "Found Hadoop in "? gate=no
  "Going to start Hadoop"? Gate "Going to start Hadoop"? gate=no
  Going to start Hadoop...
  
  expect: does "vendors area. Do you want to start it? [y/n] y\r\nGoing to start Hadoop...\r\n" (spawn_id exp6) match regular expression "Found MongoDB in"? Gate "Found MongoDB in"? gate=no
  "Found Hadoop in "? Gate "Found Hadoop in "? gate=no
  "Going to start Hadoop"? Gate "Going to start Hadoop"? gate=yes re=yes
  expect: set expect_out(0,string) "Going to start Hadoop"
  expect: set expect_out(spawn_id) "exp6"
  expect: set expect_out(buffer) "vendors area. Do you want to start it? [y/n] y\r\nGoing to start Hadoop"
  tty_raw_noecho: was raw = 0  echo = 1
  interact: received eof from spawn_id exp6
  tty_set: raw = 0, echo = 1
  tty_set: raw = 5, echo = 0
  </code></pre>
  
  <p>I've tried using <code>exit 0</code>, <code>interact</code>, <code>exp_continue</code>, <code>disconnect</code>, <code>sleep 10</code> under the last pattern, as well as expecting <code>eof</code> but nothing seems to be working. I've also tried running <code>expect start-all.exp &amp;</code> but that doesn't work either.</p>
  
  <p>When I run bin/start-all.sh manually, the script starts the necessary processes and then exits. However with expect those processes seem to get killed. How would I fix this issue?</p>