aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-04-02 13:01:32 +0100
committerRon Yorston <rmy@pobox.com>2018-04-02 13:01:32 +0100
commitb7115d6ab736c0e9968bec3460ffa5cb12c94965 (patch)
treeed739a0430fb7d34466191c5e06055ee61dccb87
parent9135f0ac53c4fb1349eb0e886f12b033a4251673 (diff)
downloadbusybox-w32-b7115d6ab736c0e9968bec3460ffa5cb12c94965.tar.gz
busybox-w32-b7115d6ab736c0e9968bec3460ffa5cb12c94965.tar.bz2
busybox-w32-b7115d6ab736c0e9968bec3460ffa5cb12c94965.zip
ash: minor forkshell fixes
- update forkshell_evalbackcmd to match the non-MinGW code; - increase the size of the buffer to hold the forkshell handle for 64-bit machines; - use memcpy to copy the globals_var structure to avoid copying bits by hand.
-rw-r--r--shell/ash.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 7448b668a..6d24fb55a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14870,7 +14870,8 @@ forkshell_evalbackcmd(struct forkshell *fs)
14870 close(pip[1]); 14870 close(pip[1]);
14871 } 14871 }
14872 eflag = 0; 14872 eflag = 0;
14873 evaltree(n, EV_EXIT); /* actually evaltreenr... */ 14873 ifsfree();
14874 evaltreenr(n, EV_EXIT);
14874 /* NOTREACHED */ 14875 /* NOTREACHED */
14875} 14876}
14876 14877
@@ -14981,7 +14982,7 @@ static int
14981spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) 14982spawn_forkshell(struct job *jp, struct forkshell *fs, int mode)
14982{ 14983{
14983 struct forkshell *new; 14984 struct forkshell *new;
14984 char buf[16]; 14985 char buf[32];
14985 const char *argv[] = { "sh", "--forkshell", NULL, NULL }; 14986 const char *argv[] = { "sh", "--forkshell", NULL, NULL };
14986 intptr_t ret; 14987 intptr_t ret;
14987 14988
@@ -15259,9 +15260,9 @@ globals_var_copy(struct globals_var *gvp)
15259 15260
15260 new = funcblock; 15261 new = funcblock;
15261 funcblock = (char *) funcblock + sizeof(struct globals_var); 15262 funcblock = (char *) funcblock + sizeof(struct globals_var);
15263 memcpy(new, gvp, sizeof(struct globals_var));
15262 15264
15263 /* shparam */ 15265 /* shparam */
15264 memcpy(&new->shellparam, &gvp->shellparam, sizeof(struct shparam));
15265 new->shellparam.malloced = 0; 15266 new->shellparam.malloced = 0;
15266 new->shellparam.p = argv_copy(gvp->shellparam.p); 15267 new->shellparam.p = argv_copy(gvp->shellparam.p);
15267 SAVE_PTR(new->shellparam.p); 15268 SAVE_PTR(new->shellparam.p);
@@ -15269,14 +15270,11 @@ globals_var_copy(struct globals_var *gvp)
15269 new->redirlist = redirtab_copy(gvp->redirlist); 15270 new->redirlist = redirtab_copy(gvp->redirlist);
15270 SAVE_PTR(new->redirlist); 15271 SAVE_PTR(new->redirlist);
15271 15272
15272 new->preverrout_fd = gvp->preverrout_fd;
15273 for (i = 0; i < VTABSIZE; i++) { 15273 for (i = 0; i < VTABSIZE; i++) {
15274 new->vartab[i] = var_copy(gvp->vartab[i]); 15274 new->vartab[i] = var_copy(gvp->vartab[i]);
15275 SAVE_PTR(new->vartab[i]); 15275 SAVE_PTR(new->vartab[i]);
15276 } 15276 }
15277 15277
15278 new->lineno = gvp->lineno;
15279 strcpy(new->linenovar, gvp->linenovar);
15280 return new; 15278 return new;
15281} 15279}
15282 15280
@@ -15359,7 +15357,7 @@ static void forkshell_print(FILE *fp, struct forkshell *fs)
15359 char *s; 15357 char *s;
15360 int count; 15358 int count;
15361 15359
15362 fprintf(fp, "size %d = %d + %d*%d + %d + %d\n\n", fs->size, 15360 fprintf(fp, "size %d = %d + %d*%d + %d + %d\n", fs->size,
15363 (int)sizeof(struct forkshell), fs->nodeptrcount, 15361 (int)sizeof(struct forkshell), fs->nodeptrcount,
15364 (int)sizeof(char *), fs->funcblocksize, fs->funcstringsize); 15362 (int)sizeof(char *), fs->funcblocksize, fs->funcstringsize);
15365 15363