aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-12-15 11:56:20 +1000
committerSteve Bennett <steveb@workware.net.au>2011-12-16 13:10:13 +1000
commit55129bef0a4cacdd0a16eec6140cac3558ffc271 (patch)
treeace190d9b05798721b17ae717733bb8415947f12
parent1209055595c76e7faae95cb22e683215654f91cc (diff)
downloadjimtcl-55129bef0a4cacdd0a16eec6140cac3558ffc271.zip
jimtcl-55129bef0a4cacdd0a16eec6140cac3558ffc271.tar.gz
jimtcl-55129bef0a4cacdd0a16eec6140cac3558ffc271.tar.bz2
use execvpe if available in [exec]
On cygwin, setting environ before execvp() doesn't work, but execvpe() does exist and works, so use that in preference Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--auto.def2
-rw-r--r--jim-exec.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/auto.def b/auto.def
index 55850e6..b52d047 100644
--- a/auto.def
+++ b/auto.def
@@ -79,7 +79,7 @@ if {[cc-check-function-in-lib socket socket]} {
define-append LDLIBS [get-define lib_socket]
}
-cc-check-functions ualarm lstat fork vfork system select
+cc-check-functions ualarm lstat fork vfork system select execvpe
cc-check-functions backtrace geteuid mkstemp realpath strptime
cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist
cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
diff --git a/jim-exec.c b/jim-exec.c
index 6008490..7da97dc 100644
--- a/jim-exec.c
+++ b/jim-exec.c
@@ -139,6 +139,10 @@ int Jim_execInit(Jim_Interp *interp)
#define JimDupFd dup
#define JimFdOpenForRead(FD) fdopen((FD), "r")
#define JimOpenForRead(NAME) open((NAME), O_RDONLY, 0)
+
+ #ifndef HAVE_EXECVPE
+ #define execvpe(ARG0, ARGV, ENV) execvp(ARG0, ARGV)
+ #endif
#endif
static const char *JimStrError(void);
@@ -983,7 +987,7 @@ badargs:
close(i);
}
- execvp(arg_array[firstArg], &arg_array[firstArg]);
+ execvpe(arg_array[firstArg], &arg_array[firstArg], Jim_GetEnviron());
/* Need to prep an error message before vfork(), just in case */
fprintf(stderr, "couldn't exec \"%s\"", arg_array[firstArg]);