]> granicus.if.org Git - python/commitdiff
Restore signalhandler in case of error. Fix type of signal handler.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 31 Dec 2002 14:30:26 +0000 (14:30 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 31 Dec 2002 14:30:26 +0000 (14:30 +0000)
Modules/posixmodule.c

index 646229e0b3bbed7ae081b70dcf9df31e550c01e6..ce0bc5b25548fef1740e4e8a88547ecba74e9a1c 100644 (file)
@@ -2744,7 +2744,7 @@ posix_openpty(PyObject *self, PyObject *args)
        char * slave_name;
 #endif
 #if defined(HAVE_DEV_PTMX) && !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY)
-       void *sig_saved;
+       PyOS_sighandler_t sig_saved;
 #ifdef sun
        extern char *ptsname();
 #endif
@@ -2769,10 +2769,16 @@ posix_openpty(PyObject *self, PyObject *args)
        if (master_fd < 0)
                return posix_error();
        sig_saved = signal(SIGCHLD, SIG_DFL);
-       if (grantpt(master_fd) < 0) /* change permission of slave */
+       /* change permission of slave */
+       if (grantpt(master_fd) < 0) {
+               signal(SIGCHLD, sig_saved);
                return posix_error();
-       if (unlockpt(master_fd) < 0) /* unlock slave */
+       }
+       /* unlock slave */
+       if (unlockpt(master_fd) < 0) {
+               signal(SIGCHLD, sig_saved);
                return posix_error();
+       }
        signal(SIGCHLD, sig_saved);
        slave_name = ptsname(master_fd); /* get name of slave */
        if (slave_name == NULL)