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 */
111 static int interrupted
;
114 PyErr_SetInterrupt(void)
119 extern int PyErr_CheckSignals(void);
122 checksignals_witharg(void * arg
)
124 return PyErr_CheckSignals();
130 extern void Py_Exit(int);
131 static char message
[] =
132 "python: to interrupt a truly hanging Python program, interrupt once more.\n";
133 switch (interrupted
++) {
138 fprintf(stderr
, message
);
140 write(2, message
, strlen(message
));
148 signal(SIGINT
, intcatcher
);
149 Py_AddPendingCall(checksignals_witharg
, NULL
);
152 static void (*old_siginthandler
)(int) = SIG_DFL
;
155 PyOS_InitInterrupts(void)
157 if ((old_siginthandler
= signal(SIGINT
, SIG_IGN
)) != SIG_IGN
)
158 signal(SIGINT
, intcatcher
);
159 #ifdef HAVE_SIGINTERRUPT
160 /* This is for SunOS and other modern BSD derivatives.
161 It means that system calls (like read()) are not restarted
162 after an interrupt. This is necessary so interrupting a
163 read() or readline() call works as expected.
164 XXX On old BSD (pure 4.2 or older) you may have to do this
166 siginterrupt(SIGINT
, 1);
167 #endif /* HAVE_SIGINTERRUPT */
171 PyOS_FiniInterrupts(void)
173 signal(SIGINT
, old_siginthandler
);
177 PyOS_InterruptOccurred(void)
191 PyEval_ReInitThreads();