'Spawn a process but simulate an error during execution in the client
path: C{os.execvpe} raises an error. It should close all the standard
fds, try to print the error encountered, and exit cleanly.'

def test_mockWithExecError(self):

    cmd = '/mock/ouch'
    d = defer.Deferred()
    p = TrivialProcessProtocol(d)
    self.mockos.raiseExec = True
    try:
        reactor.spawnProcess(p, cmd, ['ouch'], env=None, usePTY=False)
    except SystemError:
        self.assertTrue(self.mockos.exited)
        self.assertEqual(self.mockos.actions, [('fork', False), 'exec', ('exit', 1)])
        self.assertIn(0, self.mockos.closed)
        self.assertIn(1, self.mockos.closed)
        self.assertIn(2, self.mockos.closed)
        self.assertIn('RuntimeError:    Bar', self.mockos.fdio.getvalue())
    else:
        self.fail('Should    not    be    here')
