Mercurial > cpython-lru_cache-weakref
annotate Modules/signalmodule.c @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 996079744566 |
| children | 3e158e69ac5d |
| rev | line source |
|---|---|
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
2061
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2055
diff
changeset
|
3 The Netherlands. |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
15 permission. |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
3654
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 ******************************************************************/ |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
32 /* Signal module -- many thanks to Lance Ellinghaus */ |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
5287
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
34 /* XXX Signals should be recorded per thread, now we have thread state. */ |
|
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
35 |
|
1888
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
36 #include "Python.h" |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 #include "intrcheck.h" |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 |
|
5287
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
39 #ifdef MS_WIN32 |
|
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
40 #include <process.h> |
|
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
41 #endif |
|
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
42 |
| 4600 | 43 #ifdef HAVE_UNISTD_H |
| 44 #include <unistd.h> | |
| 45 #endif | |
| 46 | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 #include <signal.h> |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
49 #ifndef SIG_ERR |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
50 #define SIG_ERR ((RETSIGTYPE (*)())-1) |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
51 #endif |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
52 |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
53 #ifndef NSIG |
| 5101 | 54 #ifdef _SIGMAX |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
55 #define NSIG (_SIGMAX + 1) /* For QNX */ |
| 5101 | 56 #else |
| 57 #define NSIG (SIGMAX + 1) /* for djgpp */ | |
| 58 #endif | |
|
2055
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
59 #endif |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
60 |
|
cf31eab6ab5a
Another bulky set of minor changes.
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
61 |
| 4863 | 62 |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
63 /* |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
64 NOTES ON THE INTERACTION BETWEEN SIGNALS AND THREADS |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
65 |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
66 When threads are supported, we want the following semantics: |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
67 |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
68 - only the main thread can set a signal handler |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
69 - any thread can get a signal handler |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
70 - signals are only delivered to the main thread |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
71 |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
72 I.e. we don't support "synchronous signals" like SIGFPE (catching |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
73 this doesn't make much sense in Python anyway) nor do we support |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
74 signals as a means of inter-thread communication, since not all |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
75 thread implementations support that (at least our thread library |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
76 doesn't). |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
77 |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
78 We still have the problem that in some implementations signals |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
79 generated by the keyboard (e.g. SIGINT) are delivered to all |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
80 threads (e.g. SGI), while in others (e.g. Solaris) such signals are |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
81 delivered to one random thread (an intermediate possibility would |
| 2126 | 82 be to deliver it to the main thread -- POSIX?). For now, we have |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
83 a working implementation that works in all three cases -- the |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
84 handler ignores signals if getpid() isn't the same as in the main |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
85 thread. XXX This is a hack. |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
86 |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
87 */ |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
88 |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
89 #ifdef WITH_THREAD |
|
5730
996079744566
Add sys/types.h include for pid_t when threading.
Guido van Rossum <guido@python.org>
parents:
5287
diff
changeset
|
90 #include <sys/types.h> /* For pid_t */ |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
91 #include "thread.h" |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
92 static long main_thread; |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
93 static pid_t main_pid; |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
94 #endif |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
95 |
| 4863 | 96 static struct { |
| 97 int tripped; | |
| 98 PyObject *func; | |
| 99 } Handlers[NSIG]; | |
| 100 | |
| 101 static int is_tripped = 0; /* Speed up sigcheck() when none tripped */ | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 |
| 4863 | 103 static PyObject *DefaultHandler; |
| 104 static PyObject *IgnoreHandler; | |
| 105 static PyObject *IntHandler; | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 |
| 4863 | 108 |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
109 static PyObject * |
| 4863 | 110 signal_default_int_handler(self, arg) |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
111 PyObject *self; |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
112 PyObject *arg; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 { |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
114 PyErr_SetNone(PyExc_KeyboardInterrupt); |
| 4863 | 115 return NULL; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 |
| 4863 | 118 |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 static RETSIGTYPE |
| 4863 | 120 signal_handler(sig_num) |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
121 int sig_num; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 { |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
123 #ifdef WITH_THREAD |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
124 /* See NOTES section above */ |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
125 if (getpid() == main_pid) { |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
126 #endif |
| 4863 | 127 is_tripped++; |
| 128 Handlers[sig_num].tripped = 1; | |
|
5287
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
129 Py_AddPendingCall( |
|
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
5101
diff
changeset
|
130 (int (*) Py_PROTO((ANY *)))PyErr_CheckSignals, NULL); |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
131 #ifdef WITH_THREAD |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
132 } |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
133 #endif |
|
1888
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
134 #ifdef SIGCHLD |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
135 if (sig_num == SIGCHLD) { |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
136 /* To avoid infinite recursion, this signal remains |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
137 reset until explicit re-instated. |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
138 Don't clear the 'func' field as it is our pointer |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
139 to the Python handler... */ |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
140 return; |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
141 } |
|
be956b1efb97
* various modules: #include "Python.h" and remove most remporary
Guido van Rossum <guido@python.org>
parents:
1867
diff
changeset
|
142 #endif |
| 4863 | 143 (void *)signal(sig_num, &signal_handler); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 } |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
145 |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
146 |
| 4863 | 147 |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
148 #ifndef DONT_HAVE_SIG_ALARM |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
149 static PyObject * |
| 4863 | 150 signal_alarm(self, args) |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
151 PyObject *self; /* Not used */ |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
152 PyObject *args; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1678
diff
changeset
|
153 { |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1678
diff
changeset
|
154 int t; |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
155 if (!PyArg_Parse(args, "i", &t)) |
| 4863 | 156 return NULL; |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
157 /* alarm() returns the number of seconds remaining */ |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
158 return PyInt_FromLong(alarm(t)); |
|
1817
20e1d296fdcc
* Modules/signalmodule.c: added pause().
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
159 } |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
160 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1678
diff
changeset
|
161 |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
162 #ifndef DONT_HAVE_SIG_PAUSE |
|
2123
fd5ab7e828fc
cosmetic changes so these modules will work with the strict new naming scheme
Guido van Rossum <guido@python.org>
parents:
2076
diff
changeset
|
163 static PyObject * |
| 4863 | 164 signal_pause(self, args) |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
165 PyObject *self; /* Not used */ |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
166 PyObject *args; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 { |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
168 if (!PyArg_NoArgs(args)) |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
169 return NULL; |
| 4863 | 170 |
|
2123
fd5ab7e828fc
cosmetic changes so these modules will work with the strict new naming scheme
Guido van Rossum <guido@python.org>
parents:
2076
diff
changeset
|
171 Py_BEGIN_ALLOW_THREADS |
| 4863 | 172 (void)pause(); |
|
2123
fd5ab7e828fc
cosmetic changes so these modules will work with the strict new naming scheme
Guido van Rossum <guido@python.org>
parents:
2076
diff
changeset
|
173 Py_END_ALLOW_THREADS |
| 4863 | 174 /* make sure that any exceptions that got raised are propagated |
| 175 * back into Python | |
| 176 */ | |
| 177 if (PyErr_CheckSignals()) | |
| 178 return NULL; | |
| 179 | |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
180 Py_INCREF(Py_None); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
181 return Py_None; |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
182 } |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
183 #endif |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
184 |
| 4863 | 185 |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
186 static PyObject * |
| 4863 | 187 signal_signal(self, args) |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
188 PyObject *self; /* Not used */ |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
189 PyObject *args; |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
190 { |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
191 PyObject *obj; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 int sig_num; |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
193 PyObject *old_handler; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 RETSIGTYPE (*func)(); |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
195 if (!PyArg_Parse(args, "(iO)", &sig_num, &obj)) |
| 4863 | 196 return NULL; |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
197 #ifdef WITH_THREAD |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
198 if (get_thread_ident() != main_thread) { |
|
2564
7fbff52db087
use PyCallable_Check; split some lines
Guido van Rossum <guido@python.org>
parents:
2521
diff
changeset
|
199 PyErr_SetString(PyExc_ValueError, |
|
7fbff52db087
use PyCallable_Check; split some lines
Guido van Rossum <guido@python.org>
parents:
2521
diff
changeset
|
200 "signal only works in main thread"); |
| 4863 | 201 return NULL; |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
202 } |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
203 #endif |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 if (sig_num < 1 || sig_num >= NSIG) { |
|
2564
7fbff52db087
use PyCallable_Check; split some lines
Guido van Rossum <guido@python.org>
parents:
2521
diff
changeset
|
205 PyErr_SetString(PyExc_ValueError, |
|
7fbff52db087
use PyCallable_Check; split some lines
Guido van Rossum <guido@python.org>
parents:
2521
diff
changeset
|
206 "signal number out of range"); |
| 4863 | 207 return NULL; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 } |
| 4863 | 209 if (obj == IgnoreHandler) |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 func = SIG_IGN; |
| 4863 | 211 else if (obj == DefaultHandler) |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 func = SIG_DFL; |
|
2564
7fbff52db087
use PyCallable_Check; split some lines
Guido van Rossum <guido@python.org>
parents:
2521
diff
changeset
|
213 else if (!PyCallable_Check(obj)) { |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
214 PyErr_SetString(PyExc_TypeError, |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 "signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object"); |
| 4863 | 216 return NULL; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 else |
| 4863 | 219 func = signal_handler; |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
220 if (signal(sig_num, func) == SIG_ERR) { |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
221 PyErr_SetFromErrno(PyExc_RuntimeError); |
| 4863 | 222 return NULL; |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
223 } |
| 4863 | 224 old_handler = Handlers[sig_num].func; |
| 225 Handlers[sig_num].tripped = 0; | |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
226 Py_INCREF(obj); |
| 4863 | 227 Handlers[sig_num].func = obj; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
228 return old_handler; |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 |
| 4863 | 231 |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
232 static PyObject * |
| 4863 | 233 signal_get_signal(self, args) |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
234 PyObject *self; /* Not used */ |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
235 PyObject *args; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 { |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 int sig_num; |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
238 PyObject *old_handler; |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
239 if (!PyArg_Parse(args, "i", &sig_num)) |
| 4863 | 240 return NULL; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 if (sig_num < 1 || sig_num >= NSIG) { |
|
2564
7fbff52db087
use PyCallable_Check; split some lines
Guido van Rossum <guido@python.org>
parents:
2521
diff
changeset
|
242 PyErr_SetString(PyExc_ValueError, |
|
7fbff52db087
use PyCallable_Check; split some lines
Guido van Rossum <guido@python.org>
parents:
2521
diff
changeset
|
243 "signal number out of range"); |
| 4863 | 244 return NULL; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 } |
| 4863 | 246 old_handler = Handlers[sig_num].func; |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
247 Py_INCREF(old_handler); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 return old_handler; |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 |
| 4863 | 252 |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
253 /* List of functions defined in the module */ |
| 4863 | 254 static PyMethodDef signal_methods[] = { |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
255 #ifndef DONT_HAVE_SIG_ALARM |
| 4863 | 256 {"alarm", signal_alarm}, |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
257 #endif |
| 4863 | 258 {"signal", signal_signal}, |
| 259 {"getsignal", signal_get_signal}, | |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
260 #ifndef DONT_HAVE_SIG_PAUSE |
| 4863 | 261 {"pause", signal_pause}, |
|
2521
e7d480cf16ba
added PyErr_SetInterrupt(); NT ifdefs
Guido van Rossum <guido@python.org>
parents:
2211
diff
changeset
|
262 #endif |
| 4863 | 263 {"default_int_handler", signal_default_int_handler}, |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 {NULL, NULL} /* sentinel */ |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 }; |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 |
| 4863 | 267 |
| 268 | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 void |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
270 initsignal() |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 { |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
272 PyObject *m, *d, *x; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
273 int i; |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
274 |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
275 #ifdef WITH_THREAD |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
276 main_thread = get_thread_ident(); |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
277 main_pid = getpid(); |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
278 #endif |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
279 |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 /* Create the module and add the functions */ |
| 4863 | 281 m = Py_InitModule("signal", signal_methods); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 /* Add some symbolic constants to the module */ |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
284 d = PyModule_GetDict(m); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 |
| 4863 | 286 x = DefaultHandler = PyInt_FromLong((long)SIG_DFL); |
| 287 if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) | |
| 288 goto finally; | |
| 289 Py_DECREF(x); | |
| 290 | |
| 291 x = IgnoreHandler = PyInt_FromLong((long)SIG_IGN); | |
| 292 if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) | |
| 293 goto finally; | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 |
| 4863 | 295 x = PyInt_FromLong((long)NSIG); |
| 296 if (!x || PyDict_SetItemString(d, "NSIG", x) < 0) | |
| 297 goto finally; | |
| 298 | |
| 299 x = IntHandler = PyDict_GetItemString(d, "default_int_handler"); | |
| 300 if (!x) | |
| 301 goto finally; | |
| 302 | |
| 303 Handlers[0].tripped = 0; | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 for (i = 1; i < NSIG; i++) { |
|
1658
a862d8f4507b
Speed up checking for signals and define intrcheck differently
Guido van Rossum <guido@python.org>
parents:
1630
diff
changeset
|
305 RETSIGTYPE (*t)(); |
|
3595
6293723205a6
Use sigaction if possible
Guido van Rossum <guido@python.org>
parents:
2564
diff
changeset
|
306 #ifdef HAVE_SIGACTION |
|
6293723205a6
Use sigaction if possible
Guido van Rossum <guido@python.org>
parents:
2564
diff
changeset
|
307 struct sigaction act; |
|
6293723205a6
Use sigaction if possible
Guido van Rossum <guido@python.org>
parents:
2564
diff
changeset
|
308 sigaction(i, 0, &act); |
|
3654
66eeab5a758c
Use correct field of sigaction struct
Guido van Rossum <guido@python.org>
parents:
3595
diff
changeset
|
309 t = act.sa_handler; |
|
3595
6293723205a6
Use sigaction if possible
Guido van Rossum <guido@python.org>
parents:
2564
diff
changeset
|
310 #else |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 t = signal(i, SIG_IGN); |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 signal(i, t); |
|
3595
6293723205a6
Use sigaction if possible
Guido van Rossum <guido@python.org>
parents:
2564
diff
changeset
|
313 #endif |
| 4863 | 314 Handlers[i].tripped = 0; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 if (t == SIG_DFL) |
| 4863 | 316 Handlers[i].func = DefaultHandler; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 else if (t == SIG_IGN) |
| 4863 | 318 Handlers[i].func = IgnoreHandler; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 else |
| 4863 | 320 Handlers[i].func = Py_None; /* None of our business */ |
| 321 Py_INCREF(Handlers[i].func); | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 } |
| 4863 | 323 if (Handlers[SIGINT].func == DefaultHandler) { |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 /* Install default int handler */ |
| 4863 | 325 Py_DECREF(Handlers[SIGINT].func); |
| 326 Handlers[SIGINT].func = IntHandler; | |
| 327 Py_INCREF(IntHandler); | |
| 328 signal(SIGINT, &signal_handler); | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 #ifdef SIGHUP |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
332 x = PyInt_FromLong(SIGHUP); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
333 PyDict_SetItemString(d, "SIGHUP", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
334 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 #ifdef SIGINT |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
337 x = PyInt_FromLong(SIGINT); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
338 PyDict_SetItemString(d, "SIGINT", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
339 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
340 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
341 #ifdef SIGQUIT |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
342 x = PyInt_FromLong(SIGQUIT); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
343 PyDict_SetItemString(d, "SIGQUIT", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
344 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
345 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
346 #ifdef SIGILL |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
347 x = PyInt_FromLong(SIGILL); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
348 PyDict_SetItemString(d, "SIGILL", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
349 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
350 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
351 #ifdef SIGTRAP |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
352 x = PyInt_FromLong(SIGTRAP); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
353 PyDict_SetItemString(d, "SIGTRAP", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
354 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
355 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
356 #ifdef SIGIOT |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
357 x = PyInt_FromLong(SIGIOT); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
358 PyDict_SetItemString(d, "SIGIOT", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
359 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
360 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
361 #ifdef SIGABRT |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
362 x = PyInt_FromLong(SIGABRT); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
363 PyDict_SetItemString(d, "SIGABRT", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
364 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
365 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
366 #ifdef SIGEMT |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
367 x = PyInt_FromLong(SIGEMT); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
368 PyDict_SetItemString(d, "SIGEMT", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
369 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 #ifdef SIGFPE |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
372 x = PyInt_FromLong(SIGFPE); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
373 PyDict_SetItemString(d, "SIGFPE", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
374 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
376 #ifdef SIGKILL |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
377 x = PyInt_FromLong(SIGKILL); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
378 PyDict_SetItemString(d, "SIGKILL", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
379 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
380 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
381 #ifdef SIGBUS |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
382 x = PyInt_FromLong(SIGBUS); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
383 PyDict_SetItemString(d, "SIGBUS", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
384 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
385 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
386 #ifdef SIGSEGV |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
387 x = PyInt_FromLong(SIGSEGV); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
388 PyDict_SetItemString(d, "SIGSEGV", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
389 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
390 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
391 #ifdef SIGSYS |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
392 x = PyInt_FromLong(SIGSYS); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
393 PyDict_SetItemString(d, "SIGSYS", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
394 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
395 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
396 #ifdef SIGPIPE |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
397 x = PyInt_FromLong(SIGPIPE); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
398 PyDict_SetItemString(d, "SIGPIPE", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
399 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
401 #ifdef SIGALRM |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
402 x = PyInt_FromLong(SIGALRM); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
403 PyDict_SetItemString(d, "SIGALRM", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
404 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
405 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
406 #ifdef SIGTERM |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
407 x = PyInt_FromLong(SIGTERM); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
408 PyDict_SetItemString(d, "SIGTERM", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
409 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
411 #ifdef SIGUSR1 |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
412 x = PyInt_FromLong(SIGUSR1); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
413 PyDict_SetItemString(d, "SIGUSR1", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
414 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
415 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 #ifdef SIGUSR2 |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
417 x = PyInt_FromLong(SIGUSR2); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
418 PyDict_SetItemString(d, "SIGUSR2", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
419 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
421 #ifdef SIGCLD |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
422 x = PyInt_FromLong(SIGCLD); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
423 PyDict_SetItemString(d, "SIGCLD", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
424 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
425 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
426 #ifdef SIGCHLD |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
427 x = PyInt_FromLong(SIGCHLD); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
428 PyDict_SetItemString(d, "SIGCHLD", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
429 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
430 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
431 #ifdef SIGPWR |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
432 x = PyInt_FromLong(SIGPWR); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
433 PyDict_SetItemString(d, "SIGPWR", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
434 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
435 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
436 #ifdef SIGIO |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
437 x = PyInt_FromLong(SIGIO); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
438 PyDict_SetItemString(d, "SIGIO", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
439 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
440 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
441 #ifdef SIGURG |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
442 x = PyInt_FromLong(SIGURG); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
443 PyDict_SetItemString(d, "SIGURG", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
444 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
445 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
446 #ifdef SIGWINCH |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
447 x = PyInt_FromLong(SIGWINCH); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
448 PyDict_SetItemString(d, "SIGWINCH", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
449 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
450 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
451 #ifdef SIGPOLL |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
452 x = PyInt_FromLong(SIGPOLL); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
453 PyDict_SetItemString(d, "SIGPOLL", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
454 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
455 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
456 #ifdef SIGSTOP |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
457 x = PyInt_FromLong(SIGSTOP); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
458 PyDict_SetItemString(d, "SIGSTOP", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
459 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
460 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
461 #ifdef SIGTSTP |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
462 x = PyInt_FromLong(SIGTSTP); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
463 PyDict_SetItemString(d, "SIGTSTP", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
464 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
465 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
466 #ifdef SIGCONT |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
467 x = PyInt_FromLong(SIGCONT); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
468 PyDict_SetItemString(d, "SIGCONT", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
469 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
470 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
471 #ifdef SIGTTIN |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
472 x = PyInt_FromLong(SIGTTIN); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
473 PyDict_SetItemString(d, "SIGTTIN", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
474 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
475 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
476 #ifdef SIGTTOU |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
477 x = PyInt_FromLong(SIGTTOU); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
478 PyDict_SetItemString(d, "SIGTTOU", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
479 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
480 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
481 #ifdef SIGVTALRM |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
482 x = PyInt_FromLong(SIGVTALRM); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
483 PyDict_SetItemString(d, "SIGVTALRM", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
484 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
485 #endif |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 #ifdef SIGPROF |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
487 x = PyInt_FromLong(SIGPROF); |
|
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
488 PyDict_SetItemString(d, "SIGPROF", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
489 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
490 #endif |
|
4736
94ad56ef5073
initsignal(): Added SIGXCPU and SIGXFSZ. Left in the definitions for
Barry Warsaw <barry@python.org>
parents:
4600
diff
changeset
|
491 #ifdef SIGXCPU |
|
94ad56ef5073
initsignal(): Added SIGXCPU and SIGXFSZ. Left in the definitions for
Barry Warsaw <barry@python.org>
parents:
4600
diff
changeset
|
492 x = PyInt_FromLong(SIGXCPU); |
|
94ad56ef5073
initsignal(): Added SIGXCPU and SIGXFSZ. Left in the definitions for
Barry Warsaw <barry@python.org>
parents:
4600
diff
changeset
|
493 PyDict_SetItemString(d, "SIGXCPU", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
494 Py_XDECREF(x); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
495 #endif |
|
4736
94ad56ef5073
initsignal(): Added SIGXCPU and SIGXFSZ. Left in the definitions for
Barry Warsaw <barry@python.org>
parents:
4600
diff
changeset
|
496 #ifdef SIGXFSZ |
|
94ad56ef5073
initsignal(): Added SIGXCPU and SIGXFSZ. Left in the definitions for
Barry Warsaw <barry@python.org>
parents:
4600
diff
changeset
|
497 x = PyInt_FromLong(SIGXFSZ); |
|
94ad56ef5073
initsignal(): Added SIGXCPU and SIGXFSZ. Left in the definitions for
Barry Warsaw <barry@python.org>
parents:
4600
diff
changeset
|
498 PyDict_SetItemString(d, "SIGXFSZ", x); |
|
4920
e77585af2a21
initsignal(): Py_DECREFs really should be Py_XDECREFs in case the
Barry Warsaw <barry@python.org>
parents:
4863
diff
changeset
|
499 Py_XDECREF(x); |
|
4736
94ad56ef5073
initsignal(): Added SIGXCPU and SIGXFSZ. Left in the definitions for
Barry Warsaw <barry@python.org>
parents:
4600
diff
changeset
|
500 #endif |
| 4863 | 501 if (!PyErr_Occurred()) |
| 502 return; | |
| 503 | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
504 /* Check for errors */ |
| 4863 | 505 finally: |
| 506 Py_FatalError("can't initialize module signal"); | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
507 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 |
| 4863 | 509 |
| 510 | |
| 511 /* Declared in pyerrors.h */ | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
512 int |
|
2211
eb3e61db0dda
rename sigcheck so signal handling works again
Guido van Rossum <guido@python.org>
parents:
2126
diff
changeset
|
513 PyErr_CheckSignals() |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
514 { |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 int i; |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
516 PyObject *f; |
| 4863 | 517 |
| 518 if (!is_tripped) | |
|
1658
a862d8f4507b
Speed up checking for signals and define intrcheck differently
Guido van Rossum <guido@python.org>
parents:
1630
diff
changeset
|
519 return 0; |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
520 #ifdef WITH_THREAD |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
521 if (get_thread_ident() != main_thread) |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
522 return 0; |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
523 #endif |
| 4863 | 524 if (!(f = PyEval_GetFrame())) |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
525 f = Py_None; |
| 4863 | 526 |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
527 for (i = 1; i < NSIG; i++) { |
| 4863 | 528 if (Handlers[i].tripped) { |
| 529 PyObject *result = NULL; | |
| 530 PyObject *arglist = Py_BuildValue("(iO)", i, f); | |
| 531 Handlers[i].tripped = 0; | |
| 532 | |
| 533 if (arglist) { | |
| 534 result = PyEval_CallObject(Handlers[i].func, | |
| 535 arglist); | |
|
1867
758c1374f303
Setup.in: added tkinter; rearranged the definition of PYTHONPATH so
Guido van Rossum <guido@python.org>
parents:
1817
diff
changeset
|
536 Py_DECREF(arglist); |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
537 } |
| 4863 | 538 if (!result) |
|
5020
0eca9d5f7b2d
Arrange for PyErr_CheckSignals() to be called via Py_AddPendingCall().
Guido van Rossum <guido@python.org>
parents:
4920
diff
changeset
|
539 return -1; |
| 4863 | 540 |
| 541 Py_DECREF(result); | |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
542 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
543 } |
| 4863 | 544 is_tripped = 0; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
545 return 0; |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
546 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
547 |
| 4863 | 548 |
| 549 /* Replacements for intrcheck.c functionality | |
| 550 * Declared in pyerrors.h | |
| 551 */ | |
| 552 void | |
| 553 PyErr_SetInterrupt() | |
| 554 { | |
| 555 is_tripped++; | |
| 556 Handlers[SIGINT].tripped = 1; | |
|
5020
0eca9d5f7b2d
Arrange for PyErr_CheckSignals() to be called via Py_AddPendingCall().
Guido van Rossum <guido@python.org>
parents:
4920
diff
changeset
|
557 Py_AddPendingCall((int (*) Py_PROTO((ANY *)))PyErr_CheckSignals, NULL); |
| 4863 | 558 } |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
559 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
560 void |
| 4863 | 561 PyOS_InitInterrupts() |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
562 { |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
563 initsignal(); |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
564 } |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
565 |
|
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
566 int |
| 4863 | 567 PyOS_InterruptOccurred() |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
568 { |
| 4863 | 569 if (Handlers[SIGINT].tripped) { |
|
1678
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
570 #ifdef WITH_THREAD |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
571 if (get_thread_ident() != main_thread) |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
572 return 0; |
|
1f06f71904c2
* Modules/signalmodule.c: added thread compatibility (only main
Guido van Rossum <guido@python.org>
parents:
1658
diff
changeset
|
573 #endif |
| 4863 | 574 Handlers[SIGINT].tripped = 0; |
|
1658
a862d8f4507b
Speed up checking for signals and define intrcheck differently
Guido van Rossum <guido@python.org>
parents:
1630
diff
changeset
|
575 return 1; |
|
a862d8f4507b
Speed up checking for signals and define intrcheck differently
Guido van Rossum <guido@python.org>
parents:
1630
diff
changeset
|
576 } |
|
a862d8f4507b
Speed up checking for signals and define intrcheck differently
Guido van Rossum <guido@python.org>
parents:
1630
diff
changeset
|
577 return 0; |
|
1630
0202a72d994e
New experimental modules -- signal and sybase
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
578 } |
