From b1a419bdbed3c3dd613a7abaf99d3c2489835110bfc550dec9d11beb0b9f085d Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 13 May 2011 15:47:15 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/shells/ksh?expand=0&rev=51 --- ksh.changes | 6 +++ ksh.spec | 2 + ksh93-eintr.dif | 102 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 ksh93-eintr.dif diff --git a/ksh.changes b/ksh.changes index b70c666..884fb54 100644 --- a/ksh.changes +++ b/ksh.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri May 13 15:29:04 UTC 2011 - werner@suse.de + +- Add workaround to enforce synchronization on here documents done + for forked sub shell or processes (bnc#690623) + ------------------------------------------------------------------- Fri Mar 4 16:15:16 CET 2011 - werner@suse.de diff --git a/ksh.spec b/ksh.spec index d136579..d0c8041 100644 --- a/ksh.spec +++ b/ksh.spec @@ -73,6 +73,7 @@ Patch18: ksh93-fdfn.dif Patch19: ksh93-fdleak.dif Patch20: ksh93-argv0.dif Patch21: ksh93-export.dif +Patch22: ksh93-eintr.dif %global use_suid_exe 0 %global use_locale 1 %global debug_memleak 0 @@ -145,6 +146,7 @@ find share/ -type d -a -empty | xargs -r rm -vrf %patch19 %patch20 %patch21 +%patch22 %build typeset -i IGNORED=0x$(ps --no-headers -o ignored $$) diff --git a/ksh93-eintr.dif b/ksh93-eintr.dif new file mode 100644 index 0000000..20195a0 --- /dev/null +++ b/ksh93-eintr.dif @@ -0,0 +1,102 @@ +--- src/cmd/ksh93/sh/io.c ++++ src/cmd/ksh93/sh/io.c 2011-05-03 15:15:18.283926707 +0200 +@@ -403,6 +403,7 @@ + shp->sftable[2] = sfstderr; + sfnotify(sftrack); + sh_iostream(shp,0); ++ sh_iostream(shp,1); + /* all write steams are in the same pool and share outbuff */ + shp->outpool = sfopen(NIL(Sfio_t*),NIL(char*),"sw"); /* pool identifier */ + shp->outbuff = (char*)malloc(IOBSIZE+4); +@@ -608,7 +609,8 @@ + } + if(sp) + shp->sftable[f1] = 0; +- sh_close(f1); ++ if(shp->fdstatus[f1]!=IOCLOSE) ++ sh_close(f1); + } + return(f2); + } +@@ -1022,6 +1024,8 @@ + memset(ap, 0, ARGVAL); + if(iof&IOPUT) + ap->argflag = ARG_RAW; ++ else if(shp->subshell) ++ sh_subtmpfile(shp); + ap->argchn.ap = (struct argnod*)fname; + ap = sh_argprocsub(shp,ap); + fname = ap->argval; +@@ -2148,13 +2152,18 @@ + static ssize_t subread(Sfio_t* sp,void* buff,register size_t size,Sfdisc_t* handle) + { + register struct subfile *disp = (struct subfile*)handle; ++ ssize_t n; + NOT_USED(sp); ++ sfseek(disp->oldsp,disp->offset,SEEK_SET); + if(disp->left == 0) + return(0); + if(size > disp->left) + size = disp->left; + disp->left -= size; +- return(sfread(disp->oldsp,buff,size)); ++ n = sfread(disp->oldsp,buff,size); ++ if(size>0) ++ disp->offset += size; ++ return(n); + } + + /* +--- src/cmd/ksh93/sh/subshell.c ++++ src/cmd/ksh93/sh/subshell.c 2011-04-29 15:34:13.747926082 +0200 +@@ -235,7 +235,7 @@ + if(!sp->shpwd || np==SH_LEVELNOD || np==L_ARGNOD || np==SH_SUBSCRNOD || np==SH_NAMENOD) + return(np); + /* don't bother to save if in newer scope */ +- if(sp->var!=shp->var_tree && sp->var!=shp->var_base && shp->last_root==shp->var_tree) ++ if(sp->var!=shp->var_tree && shp->last_root==shp->var_tree) + return(np); + if((ap=nv_arrayptr(np)) && (mp=nv_opensub(np))) + { +--- src/cmd/ksh93/sh/xec.c ++++ src/cmd/ksh93/sh/xec.c 2011-05-03 15:02:23.411926136 +0200 +@@ -53,6 +53,7 @@ + + #define SH_NTFORK SH_TIMING + #define NV_BLTPFSH NV_ARRAY ++#define HERE_MEM 0x1000 + + #if _lib_nice + extern int nice(int); +@@ -2606,6 +2607,7 @@ + + pid_t sh_fork(int flags, int *jobid) + { ++ Sfio_t* aux_heredocs = NIL(Sfio_t*); + register pid_t parent; + register int sig; + #if SHOPT_FASTPIPE +@@ -2625,7 +2627,23 @@ + sh.trapnote &= ~SH_SIGTERM; + job_fork(-1); + sh.savesig = -1; ++ if (sh.heredocs) ++ { ++ aux_heredocs = sftmp(HERE_MEM); ++ if (aux_heredocs) ++ { ++ sfseek(sh.heredocs,(off_t)0,SEEK_SET); ++ sfmove(sh.heredocs,aux_heredocs,(Sfoff_t)(-1),-1); ++ sfsync(aux_heredocs); ++ } ++ } + while(_sh_fork(parent=fork(),flags,jobid) < 0); ++ if (aux_heredocs) ++ { ++ if (!parent) ++ sfswap(aux_heredocs,sh.heredocs); ++ sfclose(aux_heredocs); ++ } + sh_stats(STAT_FORKS); + sig = sh.savesig; + sh.savesig = 0;