From 470f54ec474bdededbc3df736afb50655e235fc4 Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Mon, 14 Aug 2017 15:50:13 +0200 Subject: [PATCH] Use posix exit code if last command exits due to a signal Resolves: #1471874 --- ksh-20120801-posix-exit.patch | 24 ++++++++++++++++++++++++ ksh.spec | 9 ++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ksh-20120801-posix-exit.patch diff --git a/ksh-20120801-posix-exit.patch b/ksh-20120801-posix-exit.patch new file mode 100644 index 0000000..a4b44d0 --- /dev/null +++ b/ksh-20120801-posix-exit.patch @@ -0,0 +1,24 @@ +diff --git a/src/cmd/ksh93/sh/fault.c b/src/cmd/ksh93/sh/fault.c +--- a/src/cmd/ksh93/sh/fault.c ++++ b/src/cmd/ksh93/sh/fault.c +@@ -643,7 +643,7 @@ void sh_done(void *ptr, register int sig) + sfsync((Sfio_t*)sfstdin); + sfsync((Sfio_t*)shp->outpool); + sfsync((Sfio_t*)sfstdout); +- if(savxit&SH_EXITSIG) ++ if((savxit&SH_EXITMASK) == shp->lastsig) + sig = savxit&SH_EXITMASK; + if(sig) + { +@@ -668,6 +668,12 @@ void sh_done(void *ptr, register int sig) + if(sh_isoption(SH_NOEXEC)) + kiaclose((Lex_t*)shp->lex_context); + #endif /* SHOPT_KIA */ ++ ++ /* Return POSIX exit code if last process exits due to signal */ ++ if (savxit & SH_EXITSIG) { ++ exit(128 + (savxit&SH_EXITMASK)); ++ } ++ + exit(savxit&SH_EXITMASK); + } diff --git a/ksh.spec b/ksh.spec index c75798b..45562a1 100644 --- a/ksh.spec +++ b/ksh.spec @@ -8,7 +8,7 @@ URL: http://www.kornshell.com/ #CPL everywhere else (for KSH itself) License: CPL Version: %{releasedate} -Release: 40%{?dist} +Release: 41%{?dist} Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{release_date}.tgz Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{release_date}.tgz Source2: kshcomp.conf @@ -196,6 +196,9 @@ Patch80: ksh-20120801-jobwait-sigstop.patch # rhbz#1462347 Patch81: ksh-20120801-subshell-jobwait.patch +# rhbz#1471874 +Patch82: ksh-20120801-posix-exit.patch + Conflicts: pdksh Requires: coreutils, diffutils, chkconfig BuildRequires: bison @@ -319,6 +322,10 @@ fi %config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf %changelog +* Mon Aug 14 2017 Siteshwar Vashisht - 20120801-41 +- Use posix exit code if last command exits due to a signal + Resolves: #1471874 + * Mon Aug 14 2017 Siteshwar Vashisht - 20120801-40 - Fix condition to fork subshell Resolves: #1462347