diff options
-rw-r--r-- | common-main.c | 9 | ||||
-rw-r--r-- | daemon.c | 3 | ||||
-rw-r--r-- | git.c | 7 | ||||
-rw-r--r-- | shell.c | 7 |
4 files changed, 9 insertions, 17 deletions
diff --git a/common-main.c b/common-main.c index 57c912a78e..353c6ea175 100644 --- a/common-main.c +++ b/common-main.c @@ -1,4 +1,4 @@ -#include "git-compat-util.h" +#include "cache.h" #include "exec_cmd.h" int main(int argc, char **av) @@ -9,6 +9,13 @@ int main(int argc, char **av) */ const char **argv = (const char **)av; + /* + * Always open file descriptors 0/1/2 to avoid clobbering files + * in die(). It also avoids messing up when the pipes are dup'ed + * onto stdin/stdout/stderr in the child processes we spawn. + */ + sanitize_stdfds(); + argv[0] = git_extract_argv0_path(argv[0]); return cmd_main(argc, argv); @@ -1364,8 +1364,7 @@ int cmd_main(int argc, const char **argv) if (detach) { if (daemonize()) die("--detach not supported on this platform"); - } else - sanitize_stdfds(); + } if (pid_file) write_file(pid_file, "%"PRIuMAX, (uintmax_t) getpid()); @@ -639,13 +639,6 @@ int cmd_main(int argc, const char **argv) if (!cmd) cmd = "git-help"; - /* - * Always open file descriptors 0/1/2 to avoid clobbering files - * in die(). It also avoids messing up when the pipes are dup'ed - * onto stdin/stdout/stderr in the child processes we spawn. - */ - sanitize_stdfds(); - restore_sigpipe_to_default(); git_setup_gettext(); @@ -148,13 +148,6 @@ int cmd_main(int argc, const char **argv) git_setup_gettext(); /* - * Always open file descriptors 0/1/2 to avoid clobbering files - * in die(). It also avoids messing up when the pipes are dup'ed - * onto stdin/stdout/stderr in the child processes we spawn. - */ - sanitize_stdfds(); - - /* * Special hack to pretend to be a CVS server */ if (argc == 2 && !strcmp(argv[1], "cvs server")) { |