[Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.114,2.115
Guido van Rossum
python-dev@python.org
Sat, 16 Sep 2000 09:32:25 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv31229
Modified Files:
pythonrun.c
Log Message:
Add PyOS_getsig() and PyOS_setsig() -- wrappers around signal() or
sigaction() (if HAVE_SIGACTION is defined).
Index: pythonrun.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.114
retrieving revision 2.115
diff -C2 -r2.114 -r2.115
*** pythonrun.c 2000/09/01 23:29:28 2.114
--- pythonrun.c 2000/09/16 16:32:19 2.115
***************
*** 1215,1216 ****
--- 1215,1250 ----
#endif /* USE_STACKCHECK */
+
+
+ /* Wrappers around sigaction() or signal(). */
+
+ PyOS_sighandler_t
+ PyOS_getsig(int sig)
+ {
+ #ifdef HAVE_SIGACTION
+ struct sigaction context;
+ sigaction(sig, NULL, &context);
+ return context.sa_handler;
+ #else
+ PyOS_sighandler_t handler;
+ handler = signal(sig, SIG_IGN);
+ signal(sig, handler);
+ return handler;
+ #endif
+ }
+
+ PyOS_sighandler_t
+ PyOS_setsig(int sig, PyOS_sighandler_t handler)
+ {
+ #ifdef HAVE_SIGACTION
+ struct sigaction context;
+ PyOS_sighandler_t oldhandler;
+ sigaction(sig, NULL, &context);
+ oldhandler = context.sa_handler;
+ context.sa_handler = handler;
+ sigaction(sig, &context, NULL);
+ return oldhandler;
+ #else
+ return signal(sig, handler);
+ #endif
+ }