2 /* Check for interrupts */
11 PyOS_InitInterrupts(void)
16 PyOS_FiniInterrupts(void)
21 PyOS_InterruptOccurred(void)
30 #if defined(_M_IX86) && !defined(__QNX__)
34 #if defined(MSDOS) && !defined(QUICKWIN)
38 /* This is for DJGPP's GO32 extender. I don't know how to trap
39 * control-C (There's no API for ctrl-C, and I don't want to mess with
40 * the interrupt vectors.) However, this DOES catch control-break.
47 PyOS_InitInterrupts(void)
49 _go32_want_ctrl_break(1 /* TRUE */);
53 PyOS_FiniInterrupts(void)
58 PyOS_InterruptOccurred(void)
60 return _go32_was_ctrl_break_hit();
65 /* This might work for MS-DOS (untested though): */
68 PyOS_InitInterrupts(void)
73 PyOS_FiniInterrupts(void)
78 PyOS_InterruptOccurred(void)
82 if (getch() == '\003')
92 #endif /* MSDOS && !QUICKWIN */
97 /* The Mac interrupt code has moved to macglue.c */
100 #endif /* macintosh */
105 /* Default version -- for real operating systems and for Standard C */
114 static int interrupted
;
117 PyErr_SetInterrupt(void)
122 extern int PyErr_CheckSignals(void);
125 checksignals_witharg(void * arg
)
127 return PyErr_CheckSignals();
133 extern void Py_Exit(int);
134 static char message
[] =
135 "python: to interrupt a truly hanging Python program, interrupt once more.\n";
136 switch (interrupted
++) {
141 fprintf(stderr
, message
);
143 write(2, message
, strlen(message
));
151 signal(SIGINT
, intcatcher
);
152 Py_AddPendingCall(checksignals_witharg
, NULL
);
155 static void (*old_siginthandler
)(int) = SIG_DFL
;
158 PyOS_InitInterrupts(void)
160 if ((old_siginthandler
= signal(SIGINT
, SIG_IGN
)) != SIG_IGN
)
161 signal(SIGINT
, intcatcher
);
162 #ifdef HAVE_SIGINTERRUPT
163 /* This is for SunOS and other modern BSD derivatives.
164 It means that system calls (like read()) are not restarted
165 after an interrupt. This is necessary so interrupting a
166 read() or readline() call works as expected.
167 XXX On old BSD (pure 4.2 or older) you may have to do this
169 siginterrupt(SIGINT
, 1);
170 #endif /* HAVE_SIGINTERRUPT */
174 PyOS_FiniInterrupts(void)
176 signal(SIGINT
, old_siginthandler
);
180 PyOS_InterruptOccurred(void)
194 PyEval_ReInitThreads();