1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
$NetBSD: patch-ca,v 1.1 2004/06/14 02:31:13 lukem Exp $
--- Python/pythonrun.c.orig 2004-03-23 07:41:47.000000000 +1100
+++ Python/pythonrun.c
@@ -1581,13 +1581,13 @@ initsigs(void)
{
#ifdef HAVE_SIGNAL_H
#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
+ PyOS_setsig(SIGPIPE, SIG_IGN);
#endif
#ifdef SIGXFZ
- signal(SIGXFZ, SIG_IGN);
+ PyOS_setsig(SIGXFZ, SIG_IGN);
#endif
#ifdef SIGXFSZ
- signal(SIGXFSZ, SIG_IGN);
+ PyOS_setsig(SIGXFSZ, SIG_IGN);
#endif
#endif /* HAVE_SIGNAL_H */
PyOS_InitInterrupts(); /* May imply initsignal() */
@@ -1684,20 +1684,19 @@ PyOS_sighandler_t
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;
+ struct sigaction context, ocontext;
context.sa_handler = handler;
- sigaction(sig, &context, NULL);
- return oldhandler;
+ sigemptyset(&context.sa_mask);
+ context.sa_flags = 0;
+ if (sigaction(sig, &context, &ocontext) == -1)
+ return SIG_ERR;
+ return ocontext.sa_handler;
#else
- return signal(sig, handler);
+ PyOS_sighandler_t oldhandler;
+ oldhandler = signal(sig, handler);
+#ifdef HAVE_SIGINTERRUPT
+ siginterrupt(sig, 1);
+#endif
+ return oldhandler;
#endif
}
|