From cea2575ea60d458f6109ac652bb5e9fb6db36bd6 Mon Sep 17 00:00:00 2001 From: Ray Gardner Date: Sun, 31 Mar 2024 21:07:45 -0600 Subject: [PATCH] Fix WEXITSTATUS() usage Is this the right way to check system status? --- toys/pending/awk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toys/pending/awk.c b/toys/pending/awk.c index f3519f68..3616df82 100644 --- a/toys/pending/awk.c +++ b/toys/pending/awk.c @@ -4244,7 +4244,7 @@ static int interpx(int start, int *status) // WEXITSTATUS is in sys/wait.h, but I'm not including that. // It seems to also be in stdlib.h in gcc and musl-gcc. // No idea how portable this is! - r = r >= 256 ? WEXITSTATUS(r) : r + 256; + if (WIFEXITED(r)) r = WEXITSTATUS(r); #endif drop(); push_int_val(r); -- 2.39.2