From c8b2e770cfd59132e447d3445556704b1a49fa89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Tue, 31 Dec 2002 14:30:26 +0000 Subject: [PATCH] Restore signalhandler in case of error. Fix type of signal handler. --- Modules/posixmodule.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 646229e0b3b..ce0bc5b2554 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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)