Twisted currently needs to install a SIGCHLD handler for reactor.spawnProcess to work reliably. This is problematic when Twisted is used with other libraries that depend on SIGCHLD (e.g. the standard library's subprocess module depends on SIGCHLD being left as SIG_DFL, otherwise it can get EINTR at unexpected times). Hence the reactor can be run with the installSignalHandlers=False flag, but then reactor.spawnProcess isn't reliable.
However, when run with installSignalHandlers=False Twisted could use a different strategy for notifications of subprocess termination. spawnProcess could first fork a process that keeps a single file descriptor back to the parent open, and then forks the child that the caller of spawnProcess requested. Then first subprocess could simply do:
pid = os.fork()
if pid:
returnVal = wait(pid)
os.write(fd, str(returnVal))
os.close(fd)
os._exit()
i.e. wait for the child process to finish, and then let the original process know the return value and exit. The original process would know that the subprocess was done when it saw the fd get closed, and would know what the return value was.
It's ugly, but it might be better than nothing.