]> granicus.if.org Git - python/commitdiff
Fix for r78527. It left out updating forkpty.
authorGregory P. Smith <greg@mad-scientist.com>
Mon, 1 Mar 2010 02:31:33 +0000 (02:31 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Mon, 1 Mar 2010 02:31:33 +0000 (02:31 +0000)
Modules/posixmodule.c

index 45128d32b8e4927c5b006dbdc83051340ef52804..26c6e461005150b0f4bb3c1a14d2b91a6eca0f64 100644 (file)
@@ -3762,15 +3762,18 @@ To both, return fd of newly opened pseudo-terminal.\n");
 static PyObject *
 posix_forkpty(PyObject *self, PyObject *noargs)
 {
-       int master_fd = -1, result;
+       int master_fd = -1, result = 0;
        pid_t pid;
 
        _PyImport_AcquireLock();
        pid = forkpty(&master_fd, NULL, NULL, NULL);
-       if (pid == 0)
+       if (pid == 0) {
+               /* child: this clobbers and resets the import lock. */
                PyOS_AfterFork();
-
-       result = _PyImport_ReleaseLock();
+       } else {
+               /* parent: release the import lock. */
+               result = _PyImport_ReleaseLock();
+       }
        if (pid == -1)
                return posix_error();
        if (result < 0) {