]>
Commit | Line | Data |
---|---|---|
28f540f4 | 1 | /* Definitions of status bits for `wait' et al. |
2b778ceb | 2 | Copyright (C) 1992-2021 Free Software Foundation, Inc. |
54d79e99 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
54d79e99 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
54d79e99 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
28f540f4 | 18 | |
9323b58f | 19 | #if !defined _SYS_WAIT_H && !defined _STDLIB_H |
f4017d20 | 20 | # error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead." |
5107cf1d UD |
21 | #endif |
22 | ||
23 | ||
28f540f4 RM |
24 | /* Everything extant so far uses these same bits. */ |
25 | ||
28f540f4 RM |
26 | |
27 | /* If WIFEXITED(STATUS), the low-order 8 bits of the status. */ | |
28 | #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8) | |
29 | ||
30 | /* If WIFSIGNALED(STATUS), the terminating signal. */ | |
31 | #define __WTERMSIG(status) ((status) & 0x7f) | |
32 | ||
33 | /* If WIFSTOPPED(STATUS), the signal that stopped the child. */ | |
34 | #define __WSTOPSIG(status) __WEXITSTATUS(status) | |
35 | ||
36 | /* Nonzero if STATUS indicates normal termination. */ | |
37 | #define __WIFEXITED(status) (__WTERMSIG(status) == 0) | |
38 | ||
39 | /* Nonzero if STATUS indicates termination by a signal. */ | |
a044c713 | 40 | #define __WIFSIGNALED(status) \ |
f26e84d3 | 41 | (((signed char) (((status) & 0x7f) + 1) >> 1) > 0) |
28f540f4 RM |
42 | |
43 | /* Nonzero if STATUS indicates the child is stopped. */ | |
44 | #define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f) | |
45 | ||
a044c713 RM |
46 | /* Nonzero if STATUS indicates the child continued after a stop. We only |
47 | define this if <bits/waitflags.h> provides the WCONTINUED flag bit. */ | |
48 | #ifdef WCONTINUED | |
49 | # define __WIFCONTINUED(status) ((status) == __W_CONTINUED) | |
50 | #endif | |
51 | ||
28f540f4 RM |
52 | /* Nonzero if STATUS indicates the child dumped core. */ |
53 | #define __WCOREDUMP(status) ((status) & __WCOREFLAG) | |
54 | ||
55 | /* Macros for constructing status values. */ | |
56 | #define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) | |
57 | #define __W_STOPCODE(sig) ((sig) << 8 | 0x7f) | |
a044c713 | 58 | #define __W_CONTINUED 0xffff |
28f540f4 | 59 | #define __WCOREFLAG 0x80 |