From e72ae28895b22052b7ca2eef36c039ac62671f7d Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sat, 16 Feb 2008 18:36:38 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- run-command.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'run-command.c') diff --git a/run-command.c b/run-command.c index 476d00c21..291933036 100644 --- a/run-command.c +++ b/run-command.c @@ -25,7 +25,6 @@ int start_command(struct child_process *cmd) if (pipe(fdin) < 0) return -ERR_RUN_COMMAND_PIPE; cmd->in = fdin[1]; - cmd->close_in = 1; } need_out = !cmd->no_stdout @@ -38,7 +37,6 @@ int start_command(struct child_process *cmd) return -ERR_RUN_COMMAND_PIPE; } cmd->out = fdout[0]; - cmd->close_out = 1; } need_err = !cmd->no_stderr && cmd->err < 0; @@ -157,10 +155,6 @@ static int wait_or_whine(pid_t pid) int finish_command(struct child_process *cmd) { - if (cmd->close_in) - close(cmd->in); - if (cmd->close_out) - close(cmd->out); return wait_or_whine(cmd->pid); } -- cgit v1.2.1