From c3ca46e619744ccd6c597417cc8e373149608909 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 3 Aug 2017 12:33:40 +0100 Subject: ash: fixes to wait status Replace W* macros with versions from GNU C library. Change wait status values to match. --- include/mingw.h | 6 +++--- shell/ash.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mingw.h b/include/mingw.h index 5f1074160..574a77e7c 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -184,10 +184,10 @@ int winansi_get_terminal_width_height(struct winsize *win); /* * stdlib.h */ -#define WIFEXITED(x) ((unsigned)(x) < 259) /* STILL_ACTIVE */ -#define WEXITSTATUS(x) ((x) & 0xff) -#define WIFSIGNALED(x) ((unsigned)(x) > 259) #define WTERMSIG(x) ((x) & 0x7f) +#define WIFEXITED(x) (WTERMSIG(x) == 0) +#define WEXITSTATUS(x) (((x) & 0xff00) >> 8) +#define WIFSIGNALED(x) (((signed char) (((x) & 0x7f) + 1) >> 1) > 0) #define WCOREDUMP(x) 0 int mingw_system(const char *cmd); diff --git a/shell/ash.c b/shell/ash.c index 18e53a0da..758187ccd 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4378,14 +4378,14 @@ waitpid_child(int *status, int wait_flags) pid = pidlist[1]; free(pidlist); free(proclist); - *status = 260; /* terminated by a signal */ + *status = 128 + SIGINT; /* terminated by a signal */ return pid; } GetExitCodeProcess(proclist[idx], &win_status); pid = pidlist[idx]; free(pidlist); free(proclist); - *status = (int)win_status; + *status = (int)win_status << 8; return pid; } #define waitpid(p, s, f) waitpid_child(s, f) -- cgit v1.2.3-55-g6feb