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 /* Default version -- for real operating systems and for Standard C */
103 static int interrupted
;
106 PyErr_SetInterrupt(void)
111 extern int PyErr_CheckSignals(void);
114 checksignals_witharg(void * arg
)
116 return PyErr_CheckSignals();
122 extern void Py_Exit(int);
123 static char message
[] =
124 "python: to interrupt a truly hanging Python program, interrupt once more.\n";
125 switch (interrupted
++) {
130 fprintf(stderr
, message
);
132 write(2, message
, strlen(message
));
140 PyOS_setsig(SIGINT
, intcatcher
);
141 Py_AddPendingCall(checksignals_witharg
, NULL
);
144 static void (*old_siginthandler
)(int) = SIG_DFL
;
147 PyOS_InitInterrupts(void)
149 if ((old_siginthandler
= PyOS_setsig(SIGINT
, SIG_IGN
)) != SIG_IGN
)
150 PyOS_setsig(SIGINT
, intcatcher
);
154 PyOS_FiniInterrupts(void)
156 PyOS_setsig(SIGINT
, old_siginthandler
);
160 PyOS_InterruptOccurred(void)
174 PyEval_ReInitThreads();