-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathexec.go
197 lines (159 loc) · 4.82 KB
/
exec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package wasi
import "fmt"
// ExitCode is the exit code generated by a process when exiting.
type ExitCode uint32
// Signal is a signal condition.
type Signal uint8
const (
// SIGNONE means no signal. Note that POSIX has special semantics for
// kill(pid, 0), so this value is reserved.
SIGNONE Signal = iota
// SIGHUP means hangup. Action: Terminates the process.
SIGHUP
// SIGINT is the terminate interrupt signal. Action: Terminates the
// process.
SIGINT
// SIGQUIT is the terminal quit signal. Action: Terminates the process.
SIGQUIT
// SIGILL means illegal instruction. Action: Terminates the process.
SIGILL
// SIGTRAP is the trace/breakpoint trap. Action: Terminates the process.
SIGTRAP
// SIGABRT is the process abort signal. Action: Terminates the process.
SIGABRT
// SIGBUS indicates access to an undefined portion of a memory object.
// Action: Terminates the process.
SIGBUS
// SIGFPE indicates an erroneous arithmetic operation. Action: Terminates
// the process.
SIGFPE
// SIGKILL means kill. Action: Terminates the process.
SIGKILL
// SIGUSR1 is the user-defined signal 1. Action: Terminates the process.
SIGUSR1
// SIGSEGV indicates an invalid memory reference. Action: Terminates the
// process.
SIGSEGV
// SIGUSR2 is the user-defined signal 1. Action: Terminates the process.
SIGUSR2
// SIGPIPE indicates a write on a pipe with no one to read it.
// Action: Ignored.
SIGPIPE
// SIGALRM indicates an alarm clock. Action: Terminates the process.
SIGALRM
// SIGTERM is the termination signal. Action: Terminates the process.
SIGTERM
// SIGCHLD indicates that a child process terminated, stopped, or
// continued. Action: Ignored.
SIGCHLD
// SIGCONT indicates that execution should continue, if stopped.
// Action: Continues executing, if stopped.
SIGCONT
// SIGSTOP means stop executing. Action: Stops executing.
SIGSTOP
// SIGTSTP is the terminal stop signal. Action: Stops executing.
SIGTSTP
// SIGTTIN indicates that a background process is attempting read.
// Action: Stops executing.
SIGTTIN
// SIGTTOU indicates that a background process is attempting write.
// Action: Stops executing.
SIGTTOU
// SIGURG indicates that high bandwidth data is available at a socket.
// Action: Ignored.
SIGURG
// SIGXCPU means CPU time limit exceeded. Action: Terminates the process.
SIGXCPU
// SIGXFSZ means file size limit exceeded. Action: Terminates the process.
SIGXFSZ
// SIGVTALRM means virtual timer expired. Action: Terminates the process.
SIGVTALRM
// SIGPROF means profiling timer expired. Action: Terminates the process.
SIGPROF
// SIGWINCH means window changed. Action: Ignored.
SIGWINCH
// SIGPOLL means I/O is possible. Action: Terminates the process.
SIGPOLL
// SIGPWR indicates power failure. Action: Terminates the process.
SIGPWR
// SIGSYS indicates a bad system call. Action: Terminates the process.
SIGSYS
)
func (s Signal) String() string {
if int(s) < len(signalStrings) {
return signalStrings[s]
}
return fmt.Sprintf("Signal(%d)", s)
}
func (s Signal) Name() string {
if int(s) < len(signalNames) {
return signalNames[s]
}
return fmt.Sprintf("Signal(%d)", s)
}
var signalStrings = [...]string{
SIGNONE: "no signal",
SIGHUP: "hangup",
SIGINT: "interrupt",
SIGQUIT: "quit",
SIGILL: "illegal instruction",
SIGTRAP: "trace/breakpoint trap",
SIGABRT: "abort",
SIGBUS: "bus error",
SIGFPE: "floating point exception",
SIGKILL: "killed",
SIGUSR1: "user-defined signal 1",
SIGSEGV: "segmentation fault",
SIGUSR2: "user-defined signal 2",
SIGPIPE: "broken pipe",
SIGALRM: "alarm clock",
SIGTERM: "terminated",
SIGCHLD: "child exited",
SIGCONT: "continued",
SIGSTOP: "stopped (signal)",
SIGTSTP: "stopped",
SIGTTIN: "stopped (tty input)",
SIGTTOU: "stopped (tty output)",
SIGURG: "urgent I/O condition",
SIGXCPU: "CPU time limit exceeded",
SIGXFSZ: "file size limit exceeded",
SIGVTALRM: "virtual timer expired",
SIGPROF: "profiling timer expired",
SIGWINCH: "window changed",
SIGPOLL: "I/O possible",
SIGPWR: "power failure",
SIGSYS: "bad system call",
}
var signalNames = [...]string{
SIGNONE: "SIGNONE",
SIGHUP: "SIGHUP",
SIGINT: "SIGINT",
SIGQUIT: "SIGQUIT",
SIGILL: "SIGILL",
SIGTRAP: "SIGTRAP",
SIGABRT: "SIGABRT",
SIGBUS: "SIGBUS",
SIGFPE: "SIGFPE",
SIGKILL: "SIGKILL",
SIGUSR1: "SIGUSR1",
SIGSEGV: "SIGSEGV",
SIGUSR2: "SIGUSR2",
SIGPIPE: "SIGPIPE",
SIGALRM: "SIGALRM",
SIGTERM: "SIGTERM",
SIGCHLD: "SIGCHLD",
SIGCONT: "SIGCONT",
SIGSTOP: "SIGSTOP",
SIGTSTP: "SIGTSTP",
SIGTTIN: "SIGTTIN",
SIGTTOU: "SIGTTOU",
SIGURG: "SIGURG",
SIGXCPU: "SIGXCPU",
SIGXFSZ: "SIGXFSZ",
SIGVTALRM: "SIGVTALRM",
SIGPROF: "SIGPROF",
SIGWINCH: "SIGWINCH",
SIGPOLL: "SIGPOLL",
SIGPWR: "SIGPWR",
SIGSYS: "SIGSYS",
}