Index: Modules/posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.321 diff -p -c -r2.321 posixmodule.c *** Modules/posixmodule.c 15 Jun 2004 18:49:58 -0000 2.321 --- Modules/posixmodule.c 17 Jun 2004 23:42:47 -0000 *************** posix_openpty(PyObject *self, PyObject * *** 2915,2932 **** master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */ if (master_fd < 0) return posix_error(); ! sig_saved = signal(SIGCHLD, SIG_DFL); /* change permission of slave */ if (grantpt(master_fd) < 0) { ! signal(SIGCHLD, sig_saved); return posix_error(); } /* 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) return posix_error(); --- 2915,2932 ---- master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */ if (master_fd < 0) return posix_error(); ! sig_saved = PyOS_setsig(SIGCHLD, SIG_DFL); /* change permission of slave */ if (grantpt(master_fd) < 0) { ! PyOS_setsig(SIGCHLD, sig_saved); return posix_error(); } /* unlock slave */ if (unlockpt(master_fd) < 0) { ! PyOS_setsig(SIGCHLD, sig_saved); return posix_error(); } ! PyOS_setsig(SIGCHLD, sig_saved); slave_name = ptsname(master_fd); /* get name of slave */ if (slave_name == NULL) return posix_error(); Index: Modules/signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.74 diff -p -c -r2.74 signalmodule.c *** Modules/signalmodule.c 31 Jul 2003 10:35:29 -0000 2.74 --- Modules/signalmodule.c 17 Jun 2004 23:42:47 -0000 *************** signal_handler(int sig_num) *** 137,145 **** return; } #endif - #ifdef HAVE_SIGINTERRUPT - siginterrupt(sig_num, 1); - #endif PyOS_setsig(sig_num, signal_handler); } --- 137,142 ---- *************** signal_signal(PyObject *self, PyObject * *** 217,225 **** } else func = signal_handler; - #ifdef HAVE_SIGINTERRUPT - siginterrupt(sig_num, 1); - #endif if (PyOS_setsig(sig_num, func) == SIG_ERR) { PyErr_SetFromErrno(PyExc_RuntimeError); return NULL; --- 214,219 ---- Index: Modules/socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.291 diff -p -c -r1.291 socketmodule.c *** Modules/socketmodule.c 3 Jun 2004 09:24:42 -0000 1.291 --- Modules/socketmodule.c 17 Jun 2004 23:42:51 -0000 *************** sock_initobj(PyObject *self, PyObject *a *** 2474,2480 **** /* From now on, ignore SIGPIPE and let the error checking do the work. */ #ifdef SIGPIPE ! (void) signal(SIGPIPE, SIG_IGN); #endif return 0; --- 2474,2480 ---- /* From now on, ignore SIGPIPE and let the error checking do the work. */ #ifdef SIGPIPE ! (void) PyOS_setsig(SIGPIPE, SIG_IGN); #endif return 0; *************** socket_fromfd(PyObject *self, PyObject * *** 2962,2968 **** /* From now on, ignore SIGPIPE and let the error checking do the work. */ #ifdef SIGPIPE ! (void) signal(SIGPIPE, SIG_IGN); #endif return (PyObject *) s; } --- 2962,2968 ---- /* From now on, ignore SIGPIPE and let the error checking do the work. */ #ifdef SIGPIPE ! (void) PyOS_setsig(SIGPIPE, SIG_IGN); #endif return (PyObject *) s; } Index: Parser/intrcheck.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/intrcheck.c,v retrieving revision 2.45 diff -p -c -r2.45 intrcheck.c *** Parser/intrcheck.c 20 Nov 2003 01:44:58 -0000 2.45 --- Parser/intrcheck.c 17 Jun 2004 23:42:52 -0000 *************** intcatcher(int sig) *** 137,143 **** Py_Exit(1); break; } ! signal(SIGINT, intcatcher); Py_AddPendingCall(checksignals_witharg, NULL); } --- 137,143 ---- Py_Exit(1); break; } ! PyOS_setsig(SIGINT, intcatcher); Py_AddPendingCall(checksignals_witharg, NULL); } *************** static void (*old_siginthandler)(int) = *** 146,168 **** void PyOS_InitInterrupts(void) { ! if ((old_siginthandler = signal(SIGINT, SIG_IGN)) != SIG_IGN) ! signal(SIGINT, intcatcher); ! #ifdef HAVE_SIGINTERRUPT ! /* This is for SunOS and other modern BSD derivatives. ! It means that system calls (like read()) are not restarted ! after an interrupt. This is necessary so interrupting a ! read() or readline() call works as expected. ! XXX On old BSD (pure 4.2 or older) you may have to do this ! differently! */ ! siginterrupt(SIGINT, 1); ! #endif /* HAVE_SIGINTERRUPT */ } void PyOS_FiniInterrupts(void) { ! signal(SIGINT, old_siginthandler); } int --- 146,159 ---- void PyOS_InitInterrupts(void) { ! if ((old_siginthandler = PyOS_setsig(SIGINT, SIG_IGN)) != SIG_IGN) ! PyOS_setsig(SIGINT, intcatcher); } void PyOS_FiniInterrupts(void) { ! PyOS_setsig(SIGINT, old_siginthandler); } int Index: Python/pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.205 diff -p -c -r2.205 pythonrun.c *** Python/pythonrun.c 24 Mar 2004 22:22:12 -0000 2.205 --- Python/pythonrun.c 17 Jun 2004 23:42:55 -0000 *************** static void *** 1564,1576 **** initsigs(void) { #ifdef SIGPIPE ! signal(SIGPIPE, SIG_IGN); #endif #ifdef SIGXFZ ! signal(SIGXFZ, SIG_IGN); #endif #ifdef SIGXFSZ ! signal(SIGXFSZ, SIG_IGN); #endif PyOS_InitInterrupts(); /* May imply initsignal() */ } --- 1564,1576 ---- initsigs(void) { #ifdef SIGPIPE ! PyOS_setsig(SIGPIPE, SIG_IGN); #endif #ifdef SIGXFZ ! PyOS_setsig(SIGXFZ, SIG_IGN); #endif #ifdef SIGXFSZ ! PyOS_setsig(SIGXFSZ, SIG_IGN); #endif PyOS_InitInterrupts(); /* May imply initsignal() */ } *************** PyOS_getsig(int sig) *** 1634,1651 **** { #ifdef HAVE_SIGACTION struct sigaction context; ! /* Initialize context.sa_handler to SIG_ERR which makes about as ! * much sense as anything else. It should get overwritten if ! * sigaction actually succeeds and otherwise we avoid an ! * uninitialized memory read. ! */ ! context.sa_handler = SIG_ERR; ! sigaction(sig, NULL, &context); return context.sa_handler; #else PyOS_sighandler_t handler; handler = signal(sig, SIG_IGN); ! signal(sig, handler); return handler; #endif } --- 1634,1647 ---- { #ifdef HAVE_SIGACTION struct sigaction context; ! if (sigaction(sig, NULL, &context) == -1) ! return SIG_ERR; return context.sa_handler; #else PyOS_sighandler_t handler; handler = signal(sig, SIG_IGN); ! if (handler != SIG_ERR) ! signal(sig, handler); return handler; #endif } *************** PyOS_sighandler_t *** 1654,1673 **** PyOS_setsig(int sig, PyOS_sighandler_t handler) { #ifdef HAVE_SIGACTION ! struct sigaction context; ! PyOS_sighandler_t oldhandler; ! /* Initialize context.sa_handler to SIG_ERR which makes about as ! * much sense as anything else. It should get overwritten if ! * sigaction actually succeeds and otherwise we avoid an ! * uninitialized memory read. ! */ ! context.sa_handler = SIG_ERR; ! sigaction(sig, NULL, &context); ! oldhandler = context.sa_handler; context.sa_handler = handler; ! sigaction(sig, &context, NULL); ! return oldhandler; #else ! return signal(sig, handler); #endif } --- 1650,1668 ---- PyOS_setsig(int sig, PyOS_sighandler_t handler) { #ifdef HAVE_SIGACTION ! struct sigaction context, ocontext; context.sa_handler = handler; ! sigemptyset(&context.sa_mask); ! context.sa_flags = 0; ! if (sigaction(sig, &context, &ocontext) == -1) ! return SIG_ERR; ! return ocontext.sa_handler; #else ! PyOS_sighandler_t oldhandler; ! oldhandler = signal(sig, handler); ! #ifdef HAVE_SIGINTERRUPT ! siginterrupt(sig, 1); ! #endif ! return oldhandler; #endif }