mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Improve wait statuses
This change has the insight that dwExitCode isn't an exit code but rather should be used to pass the wait status. This lets us report killing as a termination status, similar to UNIX. This change also fixes the fact that exit(259) on Windows will break the parent due way WIN32 is designed. We now work around that. It turns out that NetBSD and OpenBSD, will let you have exit codes beyond 255. This change will let you use them when it's possible.
This commit is contained in:
parent
d9d5f45e2d
commit
c8aa33e0e2
22 changed files with 259 additions and 75 deletions
|
@ -44,15 +44,15 @@
|
|||
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
|
||||
#define WCOREDUMP(s) (128 & (s))
|
||||
#define WEXITSTATUS(s) ((0xff00 & (s)) >> 8)
|
||||
#define WIFCONTINUED(s) ((s) == 0xffff)
|
||||
#define WIFEXITED(s) (!WTERMSIG(s))
|
||||
#define WIFSIGNALED(s) (((signed char)((127 & (s)) + 1) >> 1) > 0)
|
||||
#define WIFSTOPPED(s) ((255 & (s)) == 127)
|
||||
#define WSTOPSIG(s) WEXITSTATUS(s)
|
||||
#define WTERMSIG(s) (127 & (s))
|
||||
#define W_STOPCODE(s) ((s) << 8 | 0177)
|
||||
#define WTERMSIG(x) (127 & (x))
|
||||
#define WCOREDUMP(x) (128 & (x))
|
||||
#define WIFEXITED(x) (!WTERMSIG(x))
|
||||
#define WEXITSTATUS(x) ((x) >> 8)
|
||||
#define WSTOPSIG(x) ((0xff00 & (x)) >> 8)
|
||||
#define WIFSTOPPED(x) __wifstopped(x)
|
||||
#define WIFSIGNALED(x) __wifsignaled(x)
|
||||
#define WIFCONTINUED(x) __wifcontinued(x)
|
||||
#define W_STOPCODE(x) ((x) << 8 | 0177)
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
@ -234,6 +234,10 @@ ssize_t readansi(int, char *, size_t);
|
|||
ssize_t tinyprint(int, const char *, ...) nullterminated();
|
||||
#endif
|
||||
|
||||
int __wifstopped(int) pureconst;
|
||||
int __wifcontinued(int) pureconst;
|
||||
int __wifsignaled(int) pureconst;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue