path: root/builtin/replace.c
diff options
authorJeff King <>2014-06-24 09:45:46 (GMT)
committerJunio C Hamano <>2014-06-25 22:27:24 (GMT)
commit28bf9429ef2e1534be8d3a59ad236834be542b86 (patch)
tree29036aa31a53372b6b37bb2b0ad57a04a2f7f816 /builtin/replace.c
parent3cc9d87710b20c86252809e068fe309f6bb7ecc2 (diff)
avoid double close of descriptors handed to run_command
When a file descriptor is given to run_command via the "in", "out", or "err" parameters, run_command takes ownership. The descriptor will be closed in the parent process whether the process is spawned successfully or not, and closing it again is wrong. In practice this has not caused problems, because we usually close() right after start_command returns, meaning no other code has opened a descriptor in the meantime. So we just get EBADF and ignore it (rather than accidentally closing somebody else's descriptor!). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/replace.c')
1 files changed, 0 insertions, 2 deletions
diff --git a/builtin/replace.c b/builtin/replace.c
index 8507835..eb1d2ec 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -207,8 +207,6 @@ static void export_object(const unsigned char *sha1, const char *filename)
if (run_command(&cmd))
die("cat-file reported failure");
- close(fd);