From 44438725b1504f2165a8ecb4a5200f7a03dcb5b0 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 17 Mar 2021 09:33:23 +0000 Subject: [PATCH] sh_done(): fix portable exit status logic (re: d024d4c8) "savxit -= SH_EXITSIG + 128;" may have worked accidentally due to subsequent bitmasking, but is blatantly wrong . It subtracts 256 + 128 = 384 from the exit status. Use bitwise logic instead, with an octal literal 0200 instead of 128. This makes more sense in this context. --- src/cmd/ksh93/sh/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ksh93/sh/fault.c b/src/cmd/ksh93/sh/fault.c index 4d362679c..0b535b3bb 100644 --- a/src/cmd/ksh93/sh/fault.c +++ b/src/cmd/ksh93/sh/fault.c @@ -677,7 +677,7 @@ void sh_done(void *ptr, register int sig) /* Exit with portable 8-bit status (128 + signum) if last child process exits due to signal */ if (savxit & SH_EXITSIG) - savxit -= SH_EXITSIG + 128; + savxit = savxit & ~SH_EXITSIG | 0200; exit(savxit&SH_EXITMASK); }