title: Expect fails to spawn more than two commands
body: <p>I have three interactive console applications: controller, node, client.</p>
  
  <p>I am unable to handle more than two!</p>
  
  <p>The following script produces correct output.</p>
  
  <pre><code>spawn controller
  expect "controller&gt;"
  spawn node
  expect "node&gt;"
  </code></pre>
  
  <p>While this script does not.</p>
  
  <pre><code>spawn controller
  expect "controller&gt;"
  spawn node
  expect "node&gt;"
  spawn client
  expect "client&gt;"
  </code></pre>
  
  <p>And from the output of client one can conclude that controller is not running anymore.</p>
  
  <p><strong>Why? Why did it stop? How can I keep it running?</strong></p>
  
  <p>I tried the same with Python bindings. It didn't work either.</p>
  
  <p>Python 2.7, Pexpect 3.0</p>
  
  <p><strong>UPDATE: python code and output</strong></p>
  
  <p>Python code:</p>
  
  <pre><code>import pexpect
  
  def pp(t, s):
      t.expect(s)
      print t.before + t.after
  
  r = pexpect.spawn('bash ./registry.sh')
  c = pexpect.spawn ('bash ./controller.sh')
  pp(c, '&gt;')
  n = pexpect.spawn ('bash ./node.sh')
  pp(n, '&gt;')
  cl = pexpect.spawn ('bash ./client.sh')
  pp(cl, '&gt;')
  
  cl.sendintr()
  n.sendintr()
  c.sendintr()
  r.sendintr()
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>INFO  ds.controller.Main  - Starting Controller
  Nov 22, 2013 11:28:34 AM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(1)-127.0.0.1: [127.0.0.1: sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)]
  INFO  ds.controller.Main  - Registered remote object
  
  controller&gt;
  INFO  ds.node.Main  - Starting Node
  INFO  ds.node.Main  - Base folder folders/node
  INFO  ds.node.Main  - ServerSocket created
  Nov 22, 2013 11:28:34 AM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(1)-192.168.1.5: [192.168.1.5: sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)]
  INFO  ds.node.Main  - Registered remote object as NodeServer-1385116114787
  INFO  ds.node.Main  - Created folder folders/node/NodeServer-1385116114787
  DEBUG ds.node.Commands  - Connected to controller
  Nov 22, 2013 11:28:34 AM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(2)-192.168.1.5: [192.168.1.5: sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)]
  Nov 22, 2013 11:28:34 AM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(2)-192.168.1.5: [192.168.1.5: ds.node.rmi.NodeFileServerImpl[11d2b4e2:1427f5a9f6b:-7fff, -3656571857937916756]: public abstract java.lang.Integer ds.node.rmi.NodeFileServerInterface.getServerSocketPort() throws java.rmi.RemoteException]
  INFO  ds.node.rmi.NodeFileServerImpl  - Start listening on ServerSocketPort
  INFO  ds.node.rmi.NodeFileServerImpl  - Returning ServerSocketPort
  DEBUG ds.shared.socket.ServerSocketHandler  - Waiting for incomming connections
  DEBUG ds.shared.socket.ServerSocketHandler  - Accepted connection
  DEBUG ds.shared.socket.ClientSocketHandler  - Connection ID 0
  DEBUG ds.shared.socket.ServerSocketHandler  - Set clientHandler: ds.shared.socket.ClientSocketHandler@f31a3e3
  
  node&gt;
  Traceback (most recent call last):
    File "../expect/py.py", line 13, in &lt;module&gt;
      pp(cl, '&gt;')
    File "../expect/py.py", line 4, in pp
      t.expect(s)
    File "build/bdist.macosx-10.9-intel/egg/pexpect/__init__.py", line 1410, in expect
    File "build/bdist.macosx-10.9-intel/egg/pexpect/__init__.py", line 1425, in expect_list
    File "build/bdist.macosx-10.9-intel/egg/pexpect/__init__.py", line 1527, in expect_loop
  pexpect.TIMEOUT: Timeout exceeded.
  &lt;pexpect.spawn object at 0x10cd773d0&gt;
  version: 3.0
  command: /bin/bash
  args: ['/bin/bash', './client.sh']
  searcher: &lt;pexpect.searcher_re object at 0x10cd77390&gt;
  buffer (last 100 chars): 'ng, java.rmi.dgc.Lease)]\r\nINFO  ds.client.Main  - Registered remote object as Client-1385116115111\r\n'
  before (last 100 chars): 'ng, java.rmi.dgc.Lease)]\r\nINFO  ds.client.Main  - Registered remote object as Client-1385116115111\r\n'
  after: &lt;class 'pexpect.TIMEOUT'&gt;
  match: None
  match_index: None
  exitstatus: None
  flag_eof: False
  pid: 2036
  child_fd: 6
  closed: False
  timeout: 30
  delimiter: &lt;class 'pexpect.EOF'&gt;
  logfile: None
  logfile_read: None
  logfile_send: None
  maxread: 2000
  ignorecase: False
  searchwindowsize: None
  delaybeforesend: 0.05
  delayafterclose: 0.1
  delayafterterminate: 0.1
  </code></pre>
  
  <p>I suppose it happens because child processes are not interleaved. Should I use something non-blocking?</p>