comparison Python/pythonrun.c @ 14637:37397bd1f8a8 legacy-trunk

Add PyOS_getsig() and PyOS_setsig() -- wrappers around signal() or sigaction() (if HAVE_SIGACTION is defined).
author Guido van Rossum <guido@python.org>
date Sat, 16 Sep 2000 16:32:19 +0000
parents 6f6f965c5e2d
children 992460c668c1 76caf0855d1f
comparison
equal deleted inserted replaced
14636:0c303a22d9a4 14637:37397bd1f8a8
1212 #endif /* WIN32 && _MSC_VER */ 1212 #endif /* WIN32 && _MSC_VER */
1213 1213
1214 /* Alternate implementations can be added here... */ 1214 /* Alternate implementations can be added here... */
1215 1215
1216 #endif /* USE_STACKCHECK */ 1216 #endif /* USE_STACKCHECK */
1217
1218
1219 /* Wrappers around sigaction() or signal(). */
1220
1221 PyOS_sighandler_t
1222 PyOS_getsig(int sig)
1223 {
1224 #ifdef HAVE_SIGACTION
1225 struct sigaction context;
1226 sigaction(sig, NULL, &context);
1227 return context.sa_handler;
1228 #else
1229 PyOS_sighandler_t handler;
1230 handler = signal(sig, SIG_IGN);
1231 signal(sig, handler);
1232 return handler;
1233 #endif
1234 }
1235
1236 PyOS_sighandler_t
1237 PyOS_setsig(int sig, PyOS_sighandler_t handler)
1238 {
1239 #ifdef HAVE_SIGACTION
1240 struct sigaction context;
1241 PyOS_sighandler_t oldhandler;
1242 sigaction(sig, NULL, &context);
1243 oldhandler = context.sa_handler;
1244 context.sa_handler = handler;
1245 sigaction(sig, &context, NULL);
1246 return oldhandler;
1247 #else
1248 return signal(sig, handler);
1249 #endif
1250 }