Use posix exit code if last command exits due to a signal

Resolves: #1471874
This commit is contained in:
Siteshwar Vashisht 2017-08-14 15:50:13 +02:00
parent c4d3e851d9
commit 470f54ec47
2 changed files with 32 additions and 1 deletions

View File

@ -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);
}

View File

@ -8,7 +8,7 @@ URL: http://www.kornshell.com/
#CPL everywhere else (for KSH itself) #CPL everywhere else (for KSH itself)
License: CPL License: CPL
Version: %{releasedate} Version: %{releasedate}
Release: 40%{?dist} Release: 41%{?dist}
Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{release_date}.tgz 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 Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{release_date}.tgz
Source2: kshcomp.conf Source2: kshcomp.conf
@ -196,6 +196,9 @@ Patch80: ksh-20120801-jobwait-sigstop.patch
# rhbz#1462347 # rhbz#1462347
Patch81: ksh-20120801-subshell-jobwait.patch Patch81: ksh-20120801-subshell-jobwait.patch
# rhbz#1471874
Patch82: ksh-20120801-posix-exit.patch
Conflicts: pdksh Conflicts: pdksh
Requires: coreutils, diffutils, chkconfig Requires: coreutils, diffutils, chkconfig
BuildRequires: bison BuildRequires: bison
@ -319,6 +322,10 @@ fi
%config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf %config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf
%changelog %changelog
* Mon Aug 14 2017 Siteshwar Vashisht <svashisht@redhat.com> - 20120801-41
- Use posix exit code if last command exits due to a signal
Resolves: #1471874
* Mon Aug 14 2017 Siteshwar Vashisht <svashisht@redhat.com> - 20120801-40 * Mon Aug 14 2017 Siteshwar Vashisht <svashisht@redhat.com> - 20120801-40
- Fix condition to fork subshell - Fix condition to fork subshell
Resolves: #1462347 Resolves: #1462347