Skip to content

Commit

Permalink
exec: Finally get the environ right
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information
msteveb committed Jul 8, 2018
1 parent 4150444 commit 3e37fe8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions jim-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, pidtype **
int i;
pidtype pid;
char **save_environ;
#ifndef __MINGW32__
char **child_environ;
#endif
struct WaitInfoTable *table = Jim_CmdPrivData(interp);

/* Holds the args which will be used to exec */
Expand Down Expand Up @@ -1024,8 +1027,6 @@ JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, pidtype **
errorId = outputId;
}

i = strlen(arg_array[firstArg]);

/* Now fork the child */

#ifdef __MINGW32__
Expand All @@ -1035,6 +1036,9 @@ JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, pidtype **
goto error;
}
#else
i = strlen(arg_array[firstArg]);

child_environ = Jim_GetEnviron();
/*
* Make a new process and enter it into the table if the vfork
* is successful.
Expand Down Expand Up @@ -1078,7 +1082,7 @@ JimCreatePipeline(Jim_Interp *interp, int argc, Jim_Obj *const *argv, pidtype **
/* Restore SIGPIPE behaviour */
(void)signal(SIGPIPE, SIG_DFL);

execvpe(arg_array[firstArg], &arg_array[firstArg], save_environ);
execvpe(arg_array[firstArg], &arg_array[firstArg], child_environ);

if (write(fileno(stderr), "couldn't exec \"", 15) &&
write(fileno(stderr), arg_array[firstArg], i) &&
Expand Down

0 comments on commit 3e37fe8

Please sign in to comment.