Blame SOURCES/ksh-20120801-posix-exit.patch

61d8f4
diff --git a/src/cmd/ksh93/sh/fault.c b/src/cmd/ksh93/sh/fault.c
61d8f4
--- a/src/cmd/ksh93/sh/fault.c
61d8f4
+++ b/src/cmd/ksh93/sh/fault.c
61d8f4
@@ -643,7 +643,7 @@ void sh_done(void *ptr, register int sig)
61d8f4
 	sfsync((Sfio_t*)sfstdin);
61d8f4
 	sfsync((Sfio_t*)shp->outpool);
61d8f4
 	sfsync((Sfio_t*)sfstdout);
61d8f4
-	if(savxit&SH_EXITSIG)
61d8f4
+	if((savxit&SH_EXITMASK) == shp->lastsig)
61d8f4
 		sig = savxit&SH_EXITMASK;
61d8f4
 	if(sig)
61d8f4
 	{
61d8f4
@@ -668,6 +668,12 @@ void sh_done(void *ptr, register int sig)
61d8f4
 	if(sh_isoption(SH_NOEXEC))
61d8f4
 		kiaclose((Lex_t*)shp->lex_context);
61d8f4
 #endif /* SHOPT_KIA */
61d8f4
+
61d8f4
+	/* Return POSIX exit code if last process exits due to signal */
61d8f4
+	if (savxit & SH_EXITSIG) {
61d8f4
+		exit(128 + (savxit&SH_EXITMASK));
61d8f4
+	}
61d8f4
+
61d8f4
 	exit(savxit&SH_EXITMASK);
61d8f4
 }