-
Notifications
You must be signed in to change notification settings - Fork 0
/
exitstatus.c
55 lines (47 loc) · 942 Bytes
/
exitstatus.c
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
#include <sys/wait.h>
/* process exited normally */
char exitstatus_normal (status)
int status;
{
if (WIFEXITED(status)) return 1;
return 0;
}
/* process exited with a signal */
char exitstatus_crashed (status)
int status;
{
if (WIFSIGNALED(status)) return 1;
return 0;
}
/* process was stopped */
char exitstatus_stopped (status)
int status;
{
if (WIFSTOPPED(status)) return 1;
return 0;
}
/* process dumped core (!posix) */
char exitstatus_coredumped (status)
int status;
{
if (WCOREDUMP(status)) return 1;
return 0;
}
/* offer the return value */
int exitstatus_return_normal (status)
int status;
{
return (WEXITSTATUS(status));
}
/* offer the signal that forced process termination or crash */
int exitstatus_return_signal (status)
int status;
{
return (WTERMSIG(status));
}
/* offer the signal that forced the process to stop */
int exitstatus_return_stopsig (status)
int status;
{
return (WSTOPSIG(status));
}