summaryrefslogtreecommitdiff
path: root/common-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'common-main.c')
-rw-r--r--common-main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/common-main.c b/common-main.c
index 57c912a..353c6ea 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);