Commit 49b0c3ba authored by Fred Drake's avatar Fred Drake

Fix bug #392, reported by Jonathan Giddy <jon@dstc.edu.au>:

In posixmodule.c:posix_fork, the function PyOS_AfterFork is called for
both the parent and the child, despite the docs stating that it should
be called in the new (child) process.

This causes problems in the parent since the forking thread becomes the
main thread according to the signal module.

Calling PyOS_AfterFork() only in the child fixes this.  Changed for both
fork() and forkpty().
parent 589c35bc
......@@ -1755,7 +1755,8 @@ posix_fork(self, args)
pid = fork();
if (pid == -1)
return posix_error();
PyOS_AfterFork();
if (pid == 0)
PyOS_AfterFork();
return PyInt_FromLong((long)pid);
}
#endif
......@@ -1814,7 +1815,8 @@ posix_forkpty(self, args)
pid = forkpty(&master_fd, NULL, NULL, NULL);
if (pid == -1)
return posix_error();
PyOS_AfterFork();
if (pid == 0)
PyOS_AfterFork();
return Py_BuildValue("(ii)", pid, master_fd);
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment