diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-09-09 11:43:29 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-09-09 11:43:29 +0000 |
commit | 209a9a125e1e86d75c8c7a6ab7b15ba3d43f8b76 (patch) | |
tree | 6bd98847dc3b9a0d903e71b86efd77281fc35fce /win32 | |
parent | b8d5224113a2dc265f7d43e0ecc905626b9486b9 (diff) |
* win32/win32.c (do_spawn): fix the bug which the environment variables
had not spread.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c index d029a11d14..bd3b1d65eb 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -741,7 +741,9 @@ char *cmd; int status = -1; char *shell, *cmd2; int mode = NtSyncProcess ? P_WAIT : P_NOWAIT; + char **env = NULL; + env = win32_get_environ(); /* save an extra exec if possible */ if ((shell = getenv("RUBYSHELL")) != 0) { if (NtHasRedirection(cmd)) { @@ -765,15 +767,17 @@ char *cmd; argv[1] = "-c"; argv[2] = cmdline; argv[4] = NULL; - status = spawnvpe(mode, argv[0], argv, environ); + status = spawnvpe(mode, argv[0], argv, env); /* return spawnle(mode, shell, shell, "-c", cmd, (char*)0, environ); */ free(cmdline); + if (env) win32_free_environ(env); return (int)((status & 0xff) << 8); } } else if ((shell = getenv("COMSPEC")) != 0) { if (NtHasRedirection(cmd) /* || isInternalCmd(cmd) */) { - status = spawnle(mode, shell, shell, "/c", cmd, (char*)0, environ); + status = spawnle(mode, shell, shell, "/c", cmd, (char*)0, env); + if (env) win32_free_environ(env); return (int)((status & 0xff) << 8); } } @@ -792,14 +796,16 @@ char *cmd; } *a = NULL; if (argv[0]) { - if ((status = spawnvpe(mode, argv[0], argv, environ)) == -1) { + if ((status = spawnvpe(mode, argv[0], argv, env)) == -1) { free(argv); free(cmd2); + if (env) win32_free_environ(env); return -1; } } free(cmd2); free(argv); + if (env) win32_free_environ(env); return (int)((status & 0xff) << 8); } |