summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/run-command.c b/run-command.c
index f3e7abb7de..cf2d8f7fae 100644
--- a/run-command.c
+++ b/run-command.c
@@ -75,7 +75,7 @@ fail_pipe:
trace_argv_printf(cmd->argv, "trace: run_command:");
-#ifndef __MINGW32__
+#ifndef WIN32
fflush(NULL);
cmd->pid = fork();
if (!cmd->pid) {
@@ -134,6 +134,7 @@ fail_pipe:
error("cannot fork() for %s: %s", cmd->argv[0],
strerror(failed_errno = errno));
#else
+{
int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
const char **sargv = cmd->argv;
char **env = environ;
@@ -173,11 +174,8 @@ fail_pipe:
if (cmd->dir)
die("chdir in start_command() not implemented");
- if (cmd->env) {
- env = copy_environ();
- for (; *cmd->env; cmd->env++)
- env = env_setenv(env, *cmd->env);
- }
+ if (cmd->env)
+ env = make_augmented_environ(cmd->env);
if (cmd->git_cmd) {
cmd->argv = prepare_git_cmd(cmd->argv);
@@ -200,6 +198,7 @@ fail_pipe:
dup2(s1, 1), close(s1);
if (s2 >= 0)
dup2(s2, 2), close(s2);
+}
#endif
if (cmd->pid < 0) {
@@ -316,8 +315,8 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
return run_command(&cmd);
}
-#ifdef __MINGW32__
-static __stdcall unsigned run_thread(void *data)
+#ifdef WIN32
+static unsigned __stdcall run_thread(void *data)
{
struct async *async = data;
return async->proc(async->fd_for_proc, async->data);
@@ -332,7 +331,7 @@ int start_async(struct async *async)
return error("cannot create pipe: %s", strerror(errno));
async->out = pipe_out[0];
-#ifndef __MINGW32__
+#ifndef WIN32
/* Flush stdio before fork() to avoid cloning buffers */
fflush(NULL);
@@ -361,7 +360,7 @@ int start_async(struct async *async)
int finish_async(struct async *async)
{
-#ifndef __MINGW32__
+#ifndef WIN32
int ret = wait_or_whine(async->pid, "child process", 0);
#else
DWORD ret = 0;