|
|
2642b8 |
diff -up ksh-20120801/src/cmd/ksh93/sh/subshell.c.orig ksh-20120801/src/cmd/ksh93/sh/subshell.c
|
|
|
2642b8 |
--- ksh-20120801/src/cmd/ksh93/sh/subshell.c.orig 2015-08-13 15:20:14.022167794 -0300
|
|
|
2642b8 |
+++ ksh-20120801/src/cmd/ksh93/sh/subshell.c 2015-08-13 15:21:43.263088168 -0300
|
|
|
2642b8 |
@@ -481,12 +481,12 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
|
|
|
2642b8 |
{
|
|
|
2642b8 |
struct subshell sub_data;
|
|
|
2642b8 |
register struct subshell *sp = &sub_data;
|
|
|
2642b8 |
- int jmpval,nsig=0,duped=0;
|
|
|
2642b8 |
+ int jmpval,isig,nsig=0,duped=0;
|
|
|
2642b8 |
long savecurenv = shp->curenv;
|
|
|
2642b8 |
int savejobpgid = job.curpgid;
|
|
|
2642b8 |
int *saveexitval = job.exitval;
|
|
|
2642b8 |
int16_t subshell;
|
|
|
2642b8 |
- char *savsig;
|
|
|
2642b8 |
+ char **savsig;
|
|
|
2642b8 |
Sfio_t *iop=0;
|
|
|
2642b8 |
struct checkpt buff;
|
|
|
2642b8 |
struct sh_scoped savst;
|
|
|
2642b8 |
@@ -561,10 +561,13 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
|
|
|
2642b8 |
/* save trap table */
|
|
|
2642b8 |
shp->st.otrapcom = 0;
|
|
|
2642b8 |
shp->st.otrap = savst.trap;
|
|
|
2642b8 |
- if((nsig=shp->st.trapmax*sizeof(char*))>0 || shp->st.trapcom[0])
|
|
|
2642b8 |
+ if((nsig=shp->st.trapmax)>0 || shp->st.trapcom[0])
|
|
|
2642b8 |
{
|
|
|
2642b8 |
- nsig += sizeof(char*);
|
|
|
2642b8 |
- memcpy(savsig=malloc(nsig),(char*)&shp->st.trapcom[0],nsig);
|
|
|
2642b8 |
+ ++nsig;
|
|
|
2642b8 |
+ savsig = malloc(nsig * sizeof(char*));
|
|
|
2642b8 |
+ /* contents of shp->st.trapcom may change */
|
|
|
2642b8 |
+ for (isig = 0; isig < nsig; ++isig)
|
|
|
2642b8 |
+ savsig[isig] = shp->st.trapcom[isig] == Empty ? Empty : (shp->st.trapcom[isig] ? strdup(shp->st.trapcom[isig]) : NULL);
|
|
|
2642b8 |
/* this nonsense needed for $(trap) */
|
|
|
2642b8 |
shp->st.otrapcom = (char**)savsig;
|
|
|
2642b8 |
}
|
|
|
2642b8 |
@@ -732,7 +735,10 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
|
|
|
2642b8 |
shp->st.otrap = 0;
|
|
|
2642b8 |
if(nsig)
|
|
|
2642b8 |
{
|
|
|
2642b8 |
- memcpy((char*)&shp->st.trapcom[0],savsig,nsig);
|
|
|
2642b8 |
+ for (isig = 0; isig < nsig; ++isig)
|
|
|
2642b8 |
+ if (shp->st.trapcom[isig] && shp->st.trapcom[isig]!=Empty)
|
|
|
2642b8 |
+ free(shp->st.trapcom[isig]);
|
|
|
2642b8 |
+ memcpy((char*)&shp->st.trapcom[0],savsig,nsig*sizeof(char*));
|
|
|
2642b8 |
free((void*)savsig);
|
|
|
2642b8 |
}
|
|
|
2642b8 |
shp->options = sp->options;
|
|
|
2642b8 |
diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.orig ksh-20120801/src/cmd/ksh93/sh/xec.c
|
|
|
2642b8 |
--- ksh-20120801/src/cmd/ksh93/sh/xec.c.orig 2015-08-13 15:22:09.821062351 -0300
|
|
|
2642b8 |
+++ ksh-20120801/src/cmd/ksh93/sh/xec.c 2015-08-13 15:28:06.166662530 -0300
|
|
|
2642b8 |
@@ -3383,10 +3383,10 @@ int sh_funscope(int argn, char *argv[],i
|
|
|
2642b8 |
struct dolnod *argsav=0,*saveargfor;
|
|
|
2642b8 |
struct sh_scoped savst, *prevscope = shp->st.self;
|
|
|
2642b8 |
struct argnod *envlist=0;
|
|
|
2642b8 |
- int jmpval;
|
|
|
2642b8 |
+ int isig,jmpval;
|
|
|
2642b8 |
volatile int r = 0;
|
|
|
2642b8 |
int n;
|
|
|
2642b8 |
- char *savstak;
|
|
|
2642b8 |
+ char **savsig;
|
|
|
2642b8 |
struct funenv *fp = 0;
|
|
|
2642b8 |
struct checkpt *buffp = (struct checkpt*)stkalloc(shp->stk,sizeof(struct checkpt));
|
|
|
2642b8 |
Namval_t *nspace = shp->namespace;
|
|
|
2642b8 |
@@ -3435,10 +3435,13 @@ int sh_funscope(int argn, char *argv[],i
|
|
|
2642b8 |
}
|
|
|
2642b8 |
shp->st.cmdname = argv[0];
|
|
|
2642b8 |
/* save trap table */
|
|
|
2642b8 |
- if((nsig=shp->st.trapmax*sizeof(char*))>0 || shp->st.trapcom[0])
|
|
|
2642b8 |
+ if((nsig=shp->st.trapmax)>0 || shp->st.trapcom[0])
|
|
|
2642b8 |
{
|
|
|
2642b8 |
- nsig += sizeof(char*);
|
|
|
2642b8 |
- memcpy(savstak=stakalloc(nsig),(char*)&shp->st.trapcom[0],nsig);
|
|
|
2642b8 |
+ ++nsig;
|
|
|
2642b8 |
+ savsig = malloc(nsig * sizeof(char*));
|
|
|
2642b8 |
+ /* contents of shp->st.trapcom may change */
|
|
|
2642b8 |
+ for (isig = 0; isig < nsig; ++isig)
|
|
|
2642b8 |
+ savsig[isig] = shp->st.trapcom[isig] == Empty ? Empty : (shp->st.trapcom[isig] ? strdup(shp->st.trapcom[isig]) : NULL);
|
|
|
2642b8 |
}
|
|
|
2642b8 |
sh_sigreset(0);
|
|
|
2642b8 |
argsav = sh_argnew(shp,argv,&saveargfor);
|
|
|
2642b8 |
@@ -3502,10 +3505,14 @@ int sh_funscope(int argn, char *argv[],i
|
|
|
2642b8 |
shp->topscope = (Shscope_t*)prevscope;
|
|
|
2642b8 |
nv_getval(sh_scoped(shp,IFSNOD));
|
|
|
2642b8 |
if(nsig)
|
|
|
2642b8 |
- memcpy((char*)&shp->st.trapcom[0],savstak,nsig);
|
|
|
2642b8 |
+ {
|
|
|
2642b8 |
+ for (isig = 0; isig < nsig; ++isig)
|
|
|
2642b8 |
+ if (shp->st.trapcom[isig] && shp->st.trapcom[isig]!=Empty)
|
|
|
2642b8 |
+ free(shp->st.trapcom[isig]);
|
|
|
2642b8 |
+ memcpy((char*)&shp->st.trapcom[0],savsig,nsig*sizeof(char*));
|
|
|
2642b8 |
+ free((void*)savsig);
|
|
|
2642b8 |
+ }
|
|
|
2642b8 |
shp->trapnote=0;
|
|
|
2642b8 |
- if(nsig)
|
|
|
2642b8 |
- stakset(savstak,0);
|
|
|
2642b8 |
shp->options = options;
|
|
|
2642b8 |
shp->last_root = last_root;
|
|
|
2642b8 |
if(jmpval == SH_JMPSUB)
|