Not having an open FD in the 0--2 range can lead to strange results,
for example, a subsequent open() may return 2 (stderr) and then a
die() would clobber this file.
git-daemon and git-shell already guarded against this, but apparently
users also manage to trip over it in other git commands. So we call
sanitize_stdfds() during main git startup.
Since these FDs are inherited, this covers all use of 'git foo ...',
and all internal C commands when called directly. It does not fix
shell/perl commands called directly.
Signed-off-by: Thomas Rast <tr...@inf.ethz.ch>
git.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/git.c b/git.c
index 4359086..6104d5e 100644
@@ -525,6 +525,13 @@ int main(int argc, char **av)
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.
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html