2 /* Check for interrupts */
12 PyOS_InitInterrupts(void)
17 PyOS_FiniInterrupts(void)
22 PyOS_InterruptOccurred(void)
31 #if defined(_M_IX86) && !defined(__QNX__)
35 #if defined(MSDOS) && !defined(QUICKWIN)
39 /* This is for DJGPP's GO32 extender. I don't know how to trap
40 * control-C (There's no API for ctrl-C, and I don't want to mess with
41 * the interrupt vectors.) However, this DOES catch control-break.
48 PyOS_InitInterrupts(void)
50 _go32_want_ctrl_break(1 /* TRUE */);
54 PyOS_FiniInterrupts(void)
59 PyOS_InterruptOccurred(void)
61 return _go32_was_ctrl_break_hit();
66 /* This might work for MS-DOS (untested though): */
69 PyOS_InitInterrupts(void)
74 PyOS_FiniInterrupts(void)
79 PyOS_InterruptOccurred(void)
83 if (getch() == '\003')
93 #endif /* MSDOS && !QUICKWIN */
98 /* Default version -- for real operating systems and for Standard C */
104 static int interrupted
;
107 PyErr_SetInterrupt(void)
112 extern int PyErr_CheckSignals(void);
115 checksignals_witharg(void * arg
)
117 return PyErr_CheckSignals();
123 extern void Py_Exit(int);
124 static char message
[] =
125 "python: to interrupt a truly hanging Python program, interrupt once more.\n";
126 switch (interrupted
++) {
130 write(2, message
, strlen(message
));
137 PyOS_setsig(SIGINT
, intcatcher
);
138 Py_AddPendingCall(checksignals_witharg
, NULL
);
141 static void (*old_siginthandler
)(int) = SIG_DFL
;
144 PyOS_InitInterrupts(void)
146 if ((old_siginthandler
= PyOS_setsig(SIGINT
, SIG_IGN
)) != SIG_IGN
)
147 PyOS_setsig(SIGINT
, intcatcher
);
151 PyOS_FiniInterrupts(void)
153 PyOS_setsig(SIGINT
, old_siginthandler
);
157 PyOS_InterruptOccurred(void)
171 PyEval_ReInitThreads();
172 PyThread_ReInitTLS();