diff options
author | Fred Drake <fdrake@acm.org> | 2000-07-06 19:42:19 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-07-06 19:42:19 (GMT) |
commit | 49b0c3bafe8fd9818e73e3594e12a749f796eeb2 (patch) | |
tree | 642ca488a109225eda02dfb4ebbee0d179846933 /Modules/posixmodule.c | |
parent | 589c35bcc7ee2448507cedf303e3b72ede34b6ce (diff) | |
download | cpython-49b0c3bafe8fd9818e73e3594e12a749f796eeb2.zip cpython-49b0c3bafe8fd9818e73e3594e12a749f796eeb2.tar.gz cpython-49b0c3bafe8fd9818e73e3594e12a749f796eeb2.tar.bz2 |
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().
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d85b91c..eea797e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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 |