1
1
"""Stub file for the 'signal' module."""
2
2
3
+ import sys
4
+ from enum import IntEnum
3
5
from typing import Any , Callable , List , Tuple , Dict , Generic , Union , Optional , Iterable , Set
4
6
from types import FrameType
5
7
@@ -10,54 +12,115 @@ ITIMER_REAL = ... # type: int
10
12
ITIMER_VIRTUAL = ... # type: int
11
13
12
14
NSIG = ... # type: int
13
- SIGABRT = ... # type: int
14
- SIGALRM = ... # type: int
15
- SIGBUS = ... # type: int
16
- SIGCHLD = ... # type: int
17
- SIGCLD = ... # type: int
18
- SIGCONT = ... # type: int
19
- SIGFPE = ... # type: int
20
- SIGHUP = ... # type: int
21
- SIGILL = ... # type: int
22
- SIGINT = ... # type: int
23
- SIGIO = ... # type: int
24
- SIGIOT = ... # type: int
25
- SIGKILL = ... # type: int
26
- SIGPIPE = ... # type: int
27
- SIGPOLL = ... # type: int
28
- SIGPROF = ... # type: int
29
- SIGPWR = ... # type: int
30
- SIGQUIT = ... # type: int
31
- SIGRTMAX = ... # type: int
32
- SIGRTMIN = ... # type: int
33
- SIGSEGV = ... # type: int
34
- SIGSTOP = ... # type: int
35
- SIGSYS = ... # type: int
36
- SIGTERM = ... # type: int
37
- SIGTRAP = ... # type: int
38
- SIGTSTP = ... # type: int
39
- SIGTTIN = ... # type: int
40
- SIGTTOU = ... # type: int
41
- SIGURG = ... # type: int
42
- SIGUSR1 = ... # type: int
43
- SIGUSR2 = ... # type: int
44
- SIGVTALRM = ... # type: int
45
- SIGWINCH = ... # type: int
46
- SIGXCPU = ... # type: int
47
- SIGXFSZ = ... # type: int
48
-
49
- SIG_DFL = ... # type: int
50
- SIG_IGN = ... # type: int
15
+
16
+ if sys .version_info >= (3 , 5 ):
17
+ class Signals (IntEnum ):
18
+ SIGABRT = ...
19
+ SIGALRM = ...
20
+ SIGBUS = ...
21
+ SIGCHLD = ...
22
+ SIGCLD = ...
23
+ SIGCONT = ...
24
+ SIGFPE = ...
25
+ SIGHUP = ...
26
+ SIGILL = ...
27
+ SIGINT = ...
28
+ SIGIO = ...
29
+ SIGIOT = ...
30
+ SIGKILL = ...
31
+ SIGPIPE = ...
32
+ SIGPOLL = ...
33
+ SIGPROF = ...
34
+ SIGPWR = ...
35
+ SIGQUIT = ...
36
+ SIGRTMAX = ...
37
+ SIGRTMIN = ...
38
+ SIGSEGV = ...
39
+ SIGSTOP = ...
40
+ SIGSYS = ...
41
+ SIGTERM = ...
42
+ SIGTRAP = ...
43
+ SIGTSTP = ...
44
+ SIGTTIN = ...
45
+ SIGTTOU = ...
46
+ SIGURG = ...
47
+ SIGUSR1 = ...
48
+ SIGUSR2 = ...
49
+ SIGVTALRM = ...
50
+ SIGWINCH = ...
51
+ SIGXCPU = ...
52
+ SIGXFSZ = ...
53
+
54
+ class Handlers (IntEnum ):
55
+ SIG_DFL = ...
56
+ SIG_IGN = ...
57
+
58
+ SIG_DFL = Handlers .SIG_DFL
59
+ SIG_IGN = Handlers .SIG_IGN
60
+
61
+ class Sigmasks (IntEnum ):
62
+ SIG_BLOCK = ...
63
+ SIG_UNBLOCK = ...
64
+ SIG_SETMASK = ...
65
+
66
+ SIG_BLOCK = Sigmasks .SIG_BLOCK
67
+ SIG_UNBLOCK = Sigmasks .SIG_UNBLOCK
68
+ SIG_SETMASK = Sigmasks .SIG_SETMASK
69
+
70
+ _SIG = Signals
71
+ _SIGNUM = Union [int , Signals ]
72
+ _HANDLER = Union [Callable [[Signals , FrameType ], None ], int , Handlers , None ]
73
+ else :
74
+ SIG_DFL = ... # type: int
75
+ SIG_IGN = ... # type: int
76
+
77
+ SIG_BLOCK = ... # type: int
78
+ SIG_UNBLOCK = ... # type: int
79
+ SIG_SETMASK = ... # type: int
80
+
81
+ _SIG = int
82
+ _SIGNUM = int
83
+ _HANDLER = Union [Callable [[int , FrameType ], None ], int , None ]
84
+
85
+ SIGABRT = ... # type: _SIG
86
+ SIGALRM = ... # type: _SIG
87
+ SIGBUS = ... # type: _SIG
88
+ SIGCHLD = ... # type: _SIG
89
+ SIGCLD = ... # type: _SIG
90
+ SIGCONT = ... # type: _SIG
91
+ SIGFPE = ... # type: _SIG
92
+ SIGHUP = ... # type: _SIG
93
+ SIGILL = ... # type: _SIG
94
+ SIGINT = ... # type: _SIG
95
+ SIGIO = ... # type: _SIG
96
+ SIGIOT = ... # type: _SIG
97
+ SIGKILL = ... # type: _SIG
98
+ SIGPIPE = ... # type: _SIG
99
+ SIGPOLL = ... # type: _SIG
100
+ SIGPROF = ... # type: _SIG
101
+ SIGPWR = ... # type: _SIG
102
+ SIGQUIT = ... # type: _SIG
103
+ SIGRTMAX = ... # type: _SIG
104
+ SIGRTMIN = ... # type: _SIG
105
+ SIGSEGV = ... # type: _SIG
106
+ SIGSTOP = ... # type: _SIG
107
+ SIGSYS = ... # type: _SIG
108
+ SIGTERM = ... # type: _SIG
109
+ SIGTRAP = ... # type: _SIG
110
+ SIGTSTP = ... # type: _SIG
111
+ SIGTTIN = ... # type: _SIG
112
+ SIGTTOU = ... # type: _SIG
113
+ SIGURG = ... # type: _SIG
114
+ SIGUSR1 = ... # type: _SIG
115
+ SIGUSR2 = ... # type: _SIG
116
+ SIGVTALRM = ... # type: _SIG
117
+ SIGWINCH = ... # type: _SIG
118
+ SIGXCPU = ... # type: _SIG
119
+ SIGXFSZ = ... # type: _SIG
51
120
52
121
CTRL_C_EVENT = 0 # Windows
53
122
CTRL_BREAK_EVENT = 0 # Windows
54
123
55
- SIG_BLOCK = ... # type: int
56
- SIG_UNBLOCK = ... # type: int
57
- SIG_SETMASK = ... # type: int
58
-
59
- _HANDLER = Union [Callable [[int , FrameType ], None ], int , None ]
60
-
61
124
class struct_siginfo (Tuple [int , int , int , int , int , int , int ]):
62
125
def __init__ (self , sequence : Iterable [int ]) -> None : ...
63
126
@property
@@ -82,15 +145,15 @@ def default_int_handler(signum: int, frame: FrameType) -> None:
82
145
83
146
def getitimer (which : int ) -> Tuple [float , float ]: ...
84
147
85
- def getsignal (signalnum : int ) -> _HANDLER :
148
+ def getsignal (signalnum : _SIGNUM ) -> _HANDLER :
86
149
raise ValueError ()
87
150
88
151
def pause () -> None : ...
89
152
90
153
def pthread_kill (thread_id : int , signum : int ) -> None :
91
154
raise OSError ()
92
155
93
- def pthread_sigmask (how : int , mask : Iterable [int ]) -> Set [int ]:
156
+ def pthread_sigmask (how : int , mask : Iterable [int ]) -> Set [_SIGNUM ]:
94
157
raise OSError ()
95
158
96
159
def set_wakeup_fd (fd : int ) -> int : ...
@@ -100,7 +163,7 @@ def setitimer(which: int, seconds: float, interval: float = ...) -> Tuple[float,
100
163
def siginterrupt (signalnum : int , flag : bool ) -> None :
101
164
raise OSError ()
102
165
103
- def signal (signalnum : int , handler : _HANDLER ) -> _HANDLER :
166
+ def signal (signalnum : _SIGNUM , handler : _HANDLER ) -> _HANDLER :
104
167
raise OSError ()
105
168
106
169
def sigpending () -> Any :
@@ -110,7 +173,7 @@ def sigtimedwait(sigset: Iterable[int], timeout: float) -> Optional[struct_sigin
110
173
raise OSError ()
111
174
raise ValueError ()
112
175
113
- def sigwait (sigset : Iterable [int ]) -> int :
176
+ def sigwait (sigset : Iterable [int ]) -> _SIGNUM :
114
177
raise OSError ()
115
178
116
179
def sigwaitinfo (sigset : Iterable [int ]) -> struct_siginfo :
0 commit comments