]> granicus.if.org Git - python/commitdiff
Fix posix.fork1() / os.fork1() to only call PyOS_AfterFork() in the child
authorGregory P. Smith <greg@mad-scientist.com>
Mon, 14 Jul 2008 06:06:48 +0000 (06:06 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Mon, 14 Jul 2008 06:06:48 +0000 (06:06 +0000)
process rather than both parent and child.

Does anyone actually use fork1()?  It appears to be a Solaris thing
but if Python is built with pthreads on Solaris, fork1() and fork()
should be the same.

Modules/posixmodule.c

index 8f32fd43497a6560f40204cd377e6e995212e87e..d8c81b6a581717d4d70516f243be4966ceba8a1e 100644 (file)
@@ -3597,7 +3597,8 @@ posix_fork1(PyObject *self, PyObject *noargs)
        pid_t pid = fork1();
        if (pid == -1)
                return posix_error();
-       PyOS_AfterFork();
+       if (pid == 0)
+               PyOS_AfterFork();
        return PyInt_FromLong(pid);
 }
 #endif