From 4258df1936aa7aba55d4408f7175208b91577077 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Jun 10 2013 13:04:01 +0000 Subject: monitor mode in scripts wasn't working --- diff --git a/ksh-20120801-kshmfix.patch b/ksh-20120801-kshmfix.patch new file mode 100644 index 0000000..72c792a --- /dev/null +++ b/ksh-20120801-kshmfix.patch @@ -0,0 +1,53 @@ +diff -up ksh-20120801/src/cmd/ksh93/sh/main.c.monintoron ksh-20120801/src/cmd/ksh93/sh/main.c +--- ksh-20120801/src/cmd/ksh93/sh/main.c.monintoron 2013-05-31 10:15:02.738828102 +0200 ++++ ksh-20120801/src/cmd/ksh93/sh/main.c 2013-05-31 10:15:36.057095262 +0200 +@@ -406,10 +406,10 @@ static void exfile(register Shell_t *shp + { + buff.mode = SH_JMPEXIT; + sh_onoption(SH_TRACKALL); +- sh_offoption(SH_MONITOR); + } + sh_offstate(SH_INTERACTIVE); +- sh_offstate(SH_MONITOR); ++ if(sh_isoption(SH_MONITOR)) ++ sh_onstate(SH_MONITOR); + sh_offstate(SH_HISTORY); + sh_offoption(SH_HISTORY); + } +diff -up ksh-20120801/src/cmd/ksh93/sh/jobs.c.orig ksh-20120801/src/cmd/ksh93/sh/jobs.c +--- ksh-20120801/src/cmd/ksh93/sh/jobs.c.orig 2013-05-31 10:12:28.358590452 +0200 ++++ ksh-20120801/src/cmd/ksh93/sh/jobs.c 2013-05-31 10:16:51.203697890 +0200 +@@ -548,7 +548,7 @@ int job_reap(register int sig) + { + px = job_byjid((int)pw->p_job); + for(; px && (px->p_flag&P_DONE); px=px->p_nxtproc); +- if(!px) ++ if(!px && sh_isoption(SH_INTERACTIVE)) + tcsetpgrp(JOBTTY,job.mypid); + } + #ifndef SHOPT_BGX +@@ -842,10 +842,11 @@ static void job_set(register struct proc + + static void job_reset(register struct process *pw) + { ++ Shell_t *shp = pw->p_shp; + /* save the terminal state for current job */ + #ifdef SIGTSTP + job_fgrp(pw,tcgetpgrp(job.fd)); +- if(tcsetpgrp(job.fd,job.mypid) !=0) ++ if(sh_isoption(SH_INTERACTIVE) && tcsetpgrp(job.fd,job.mypid) !=0) + return; + #endif /* SIGTSTP */ + /* force the following tty_get() to do a tcgetattr() unless fg */ +diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.orig ksh-20120801/src/cmd/ksh93/sh/xec.c +--- ksh-20120801/src/cmd/ksh93/sh/xec.c.orig 2013-05-31 10:12:27.000000000 +0200 ++++ ksh-20120801/src/cmd/ksh93/sh/xec.c 2013-05-31 10:18:14.650367185 +0200 +@@ -2201,7 +2201,7 @@ int sh_exec(register const Shnode_t *t, + } + shp->exitval = n; + #ifdef SIGTSTP +- if(!pipejob && sh_isstate(SH_MONITOR)) ++ if(!pipejob && sh_isstate(SH_MONITOR) && sh_isoption(SH_INTERACTIVE)) + tcsetpgrp(JOBTTY,shp->gd->pid); + #endif /*SIGTSTP */ + job.curpgid = savepgid; diff --git a/ksh.spec b/ksh.spec index a7beac6..4222e2d 100644 --- a/ksh.spec +++ b/ksh.spec @@ -6,7 +6,7 @@ URL: http://www.kornshell.com/ Group: System Environment/Shells License: EPL Version: 20120801 -Release: 8%{?dist} +Release: 9%{?dist} Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{releasedate}.tgz Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{releasedate}.tgz Source2: kshcomp.conf @@ -25,6 +25,7 @@ Patch4: ksh-20120801-cdfix.patch Patch5: ksh-20120801-tabfix.patch Patch6: ksh-20120801-cdfix2.patch Patch7: ksh-20130214-fixkill.patch +Patch8: ksh-20120801-kshmfix.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Conflicts: pdksh @@ -51,6 +52,7 @@ with "sh" (the Bourne Shell). %patch5 -p1 -b .tabfix %patch6 -p1 -b .cdfix2 %patch7 -p1 -b .fixkill +%patch8 -p1 -b .kshmfix #/dev/fd test does not work because of mock sed -i 's|ls /dev/fd|ls /proc/self/fd|' src/cmd/ksh93/features/options @@ -145,6 +147,9 @@ fi rm -rf $RPM_BUILD_ROOT %changelog +* Mon Jun 10 2013 Michal Hlavinka - 20120801-9 +- monitor mode in scripts wasn't working + * Thu Mar 07 2013 Michal Hlavinka - 20120801-8 - fix another reproducer for tab completion