Changeset 388 for python/vendor/current/Parser/intrcheck.c
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Parser/intrcheck.c
r2 r388 22 22 PyOS_InterruptOccurred(void) 23 23 { 24 24 _wyield(); 25 25 } 26 26 … … 48 48 PyOS_InitInterrupts(void) 49 49 { 50 50 _go32_want_ctrl_break(1 /* TRUE */); 51 51 } 52 52 … … 59 59 PyOS_InterruptOccurred(void) 60 60 { 61 61 return _go32_was_ctrl_break_hit(); 62 62 } 63 63 … … 79 79 PyOS_InterruptOccurred(void) 80 80 { 81 82 83 84 85 86 81 int interrupted = 0; 82 while (kbhit()) { 83 if (getch() == '\003') 84 interrupted = 1; 85 } 86 return interrupted; 87 87 } 88 88 … … 107 107 PyErr_SetInterrupt(void) 108 108 { 109 109 interrupted = 1; 110 110 } 111 111 … … 115 115 checksignals_witharg(void * arg) 116 116 { 117 117 return PyErr_CheckSignals(); 118 118 } 119 119 … … 121 121 intcatcher(int sig) 122 122 { 123 124 123 extern void Py_Exit(int); 124 static char message[] = 125 125 "python: to interrupt a truly hanging Python program, interrupt once more.\n"; 126 127 128 129 126 switch (interrupted++) { 127 case 0: 128 break; 129 case 1: 130 130 #ifdef RISCOS 131 131 fprintf(stderr, message); 132 132 #else 133 133 write(2, message, strlen(message)); 134 134 #endif 135 136 137 138 139 140 141 142 135 break; 136 case 2: 137 interrupted = 0; 138 Py_Exit(1); 139 break; 140 } 141 PyOS_setsig(SIGINT, intcatcher); 142 Py_AddPendingCall(checksignals_witharg, NULL); 143 143 } 144 144 … … 148 148 PyOS_InitInterrupts(void) 149 149 { 150 151 150 if ((old_siginthandler = PyOS_setsig(SIGINT, SIG_IGN)) != SIG_IGN) 151 PyOS_setsig(SIGINT, intcatcher); 152 152 } 153 153 … … 155 155 PyOS_FiniInterrupts(void) 156 156 { 157 157 PyOS_setsig(SIGINT, old_siginthandler); 158 158 } 159 159 … … 161 161 PyOS_InterruptOccurred(void) 162 162 { 163 164 165 166 163 if (!interrupted) 164 return 0; 165 interrupted = 0; 166 return 1; 167 167 } 168 168 … … 173 173 { 174 174 #ifdef WITH_THREAD 175 176 175 PyEval_ReInitThreads(); 176 PyThread_ReInitTLS(); 177 177 #endif 178 178 }
Note:
See TracChangeset
for help on using the changeset viewer.