waitstatus.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020: #if !defined _SYS_WAIT_H && !defined _STDLIB_H
021: # error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
022: #endif
023:
024:
025:
026:
027:
028:
029: #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
030:
031:
032: #define __WTERMSIG(status) ((status) & 0x7f)
033:
034:
035: #define __WSTOPSIG(status) __WEXITSTATUS(status)
036:
037:
038: #define __WIFEXITED(status) (__WTERMSIG(status) == 0)
039:
040:
041: #define __WIFSIGNALED(status) \
042: (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
043:
044:
045: #define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
046:
047:
048:
049: #ifdef WCONTINUED
050: # define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
051: #endif
052:
053:
054: #define __WCOREDUMP(status) ((status) & __WCOREFLAG)
055:
056:
057: #define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
058: #define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
059: #define __W_CONTINUED 0xffff
060: #define __WCOREFLAG 0x80
061:
062:
063: #ifdef __USE_BSD
064:
065: # include <endian.h>
066:
067: union wait
068: {
069: int w_status;
070: struct
071: {
072: # if __BYTE_ORDER == __LITTLE_ENDIAN
073: unsigned int __w_termsig:7;
074: unsigned int __w_coredump:1;
075: unsigned int __w_retcode:8;
076: unsigned int:16;
077: # endif
078: # if __BYTE_ORDER == __BIG_ENDIAN
079: unsigned int:16;
080: unsigned int __w_retcode:8;
081: unsigned int __w_coredump:1;
082: unsigned int __w_termsig:7;
083: # endif
084: } __wait_terminated;
085: struct
086: {
087: # if __BYTE_ORDER == __LITTLE_ENDIAN
088: unsigned int __w_stopval:8;
089: unsigned int __w_stopsig:8;
090: unsigned int:16;
091: # endif
092: # if __BYTE_ORDER == __BIG_ENDIAN
093: unsigned int:16;
094: unsigned int __w_stopsig:8;
095: unsigned int __w_stopval:8;
096: # endif
097: } __wait_stopped;
098: };
099:
100: # define w_termsig __wait_terminated.__w_termsig
101: # define w_coredump __wait_terminated.__w_coredump
102: # define w_retcode __wait_terminated.__w_retcode
103: # define w_stopsig __wait_stopped.__w_stopsig
104: # define w_stopval __wait_stopped.__w_stopval
105:
106: #endif
107:
© Andrew Scott 2006 -
2025,
All Rights Reserved