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
++) {
140 write(2, message
, strlen(message
));
147 signal(SIGINT
, intcatcher
);
148 Py_AddPendingCall(checksignals_witharg
, NULL
);
151 static void (*old_siginthandler
)(int) = SIG_DFL
;
154 PyOS_InitInterrupts(void)
156 if ((old_siginthandler
= signal(SIGINT
, SIG_IGN
)) != SIG_IGN
)
157 signal(SIGINT
, intcatcher
);
158 #ifdef HAVE_SIGINTERRUPT
159 /* This is for SunOS and other modern BSD derivatives.
160 It means that system calls (like read()) are not restarted
161 after an interrupt. This is necessary so interrupting a
162 read() or readline() call works as expected.
163 XXX On old BSD (pure 4.2 or older) you may have to do this
165 siginterrupt(SIGINT
, 1);
166 #endif /* HAVE_SIGINTERRUPT */
170 PyOS_FiniInterrupts(void)
172 signal(SIGINT
, old_siginthandler
);
176 PyOS_InterruptOccurred(void)
190 PyEval_ReInitThreads();