start_command(), .in/.out/.err = -1: Callers must close the file descriptor

By setting .in, .out, or .err members of struct child_process to -1, the
callers of start_command() can request that a pipe is allocated that talks
to the child process and one end is returned by replacing -1 with the
file descriptor.

Previously, a flag was set (for .in and .out, but not .err) to signal
finish_command() to close the pipe end that start_command() had handed out,
so it was optional for callers to close the pipe, and many already do so.
Now we make it mandatory to close the pipe.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Sixt
2008-02-16 18:36:38 +01:00
committed by Junio C Hamano
parent 923d44aeb7
commit e72ae28895
8 changed files with 9 additions and 11 deletions

View File

@ -71,6 +71,7 @@ static int pack_objects(int fd, struct ref *refs)
refs = refs->next;
}
close(po.in);
if (finish_command(&po))
return error("pack-objects died with strange error");
return 0;