From 13852e865c87c0147ab4bf4d1fdc5be3a711cbbc Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 1 Aug 2023 10:32:04 +0300 Subject: [PATCH] LibC: sys/wait.h now has proper exit status macros We use the same format as basically every implementation --- libc/include/sys/wait.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h index c5d95f19..684e46ba 100644 --- a/libc/include/sys/wait.h +++ b/libc/include/sys/wait.h @@ -20,17 +20,14 @@ __BEGIN_DECLS #define WNOWAIT 0x10 #define WSTOPPED 0x20 -#define WEXITSTATUS(status) (status & 0xFF) -#define WIFEXITED(status) (WEXITSTATUS(status) != 0) +#define WEXITSTATUS(status) (((status) >> 8) & 0xFF) +#define WSTOPSIG(status) WEXITSTATUS(status) +#define WTERMSIG(status) ((status) & 0x7F) +#define WIFEXITED(status) (WTERMSIG(status) == 0) +#define WIFSIGNALED(status) (((status) & 0x7F) > 0 && ((status) & 0x7F) < 0x7F) +#define WIFSTOPPED(status) (((status) & 0xFF) == 0x7F) -// FIXME -#if 0 -#define WIFCONTINUED -#define WIFSIGNALED -#define WIFSTOPPED -#define WSTOPSIG -#define WTERMSIG -#endif +#define __WGENEXITCODE(ret, sig) (((ret) << 8) | (sig)) typedef enum {