diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-08-29 09:16:39 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-29 09:16:39 +0200 |
commit | 445cac18c015809a7fcb4a570d3c6571b1ddaf7d (patch) | |
tree | 89eeb8e6618d9eb582ea5bd1a2cf781625ebc001 /shell.c | |
parent | git-p4: Fix checkout bug when using --import-local. (diff) | |
parent | tutorial: gentler illustration of Alice/Bob workflow using gitk (diff) | |
download | git-445cac18c015809a7fcb4a570d3c6571b1ddaf7d.tar.xz git-445cac18c015809a7fcb4a570d3c6571b1ddaf7d.zip |
Merge branch 'maint'
* maint:
tutorial: gentler illustration of Alice/Bob workflow using gitk
pretty=format: respect date format options
make git-shell paranoid about closed stdin/stdout/stderr
Document gitk --argscmd flag.
Fix '--dirstat' with cross-directory renaming
for-each-ref: Allow a trailing slash in the patterns
Diffstat (limited to 'shell.c')
-rw-r--r-- | shell.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -48,6 +48,19 @@ int main(int argc, char **argv) { char *prog; struct commands *cmd; + int devnull_fd; + + /* + * Always open file descriptors 0/1/2 to avoid clobbering files + * in die(). It also avoids not messing up when the pipes are + * dup'ed onto stdin/stdout/stderr in the child processes we spawn. + */ + devnull_fd = open("/dev/null", O_RDWR); + while (devnull_fd >= 0 && devnull_fd <= 2) + devnull_fd = dup(devnull_fd); + if (devnull_fd == -1) + die("opening /dev/null failed (%s)", strerror(errno)); + close (devnull_fd); /* * Special hack to pretend to be a CVS server |