Code

autoconf: Add link tests to each AC_CHECK_FUNC() test
[git.git] / run-command.c
index a3b28a64dc2d1b888b0ba2a135be10fe04651201..c90cdc50e3165bcdb798c85b2dc7b929a9b0a144 100644 (file)
@@ -68,6 +68,7 @@ int start_command(struct child_process *cmd)
        trace_argv_printf(cmd->argv, "trace: run_command:");
 
 #ifndef __MINGW32__
+       fflush(NULL);
        cmd->pid = fork();
        if (!cmd->pid) {
                if (cmd->no_stdin)
@@ -110,6 +111,8 @@ int start_command(struct child_process *cmd)
                                        unsetenv(*cmd->env);
                        }
                }
+               if (cmd->preexec_cb)
+                       cmd->preexec_cb();
                if (cmd->git_cmd) {
                        execv_git_cmd(cmd->argv);
                } else {
@@ -270,14 +273,6 @@ int run_command_v_opt(const char **argv, int opt)
        return run_command(&cmd);
 }
 
-int run_command_v_opt_cd(const char **argv, int opt, const char *dir)
-{
-       struct child_process cmd;
-       prepare_run_command_v_opt(&cmd, argv, opt);
-       cmd.dir = dir;
-       return run_command(&cmd);
-}
-
 int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
 {
        struct child_process cmd;
@@ -304,6 +299,9 @@ int start_async(struct async *async)
        async->out = pipe_out[0];
 
 #ifndef __MINGW32__
+       /* Flush stdio before fork() to avoid cloning buffers */
+       fflush(NULL);
+
        async->pid = fork();
        if (async->pid < 0) {
                error("fork (async) failed: %s", strerror(errno));