From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 3/7] Automatically close stderr pipes created by run_command
Date: Wed, 30 Jan 2008 01:22:02 -0500 [thread overview]
Message-ID: <20080130062202.GC15838@spearce.org> (raw)
Like the out pipe and in pipe, we now automatically close the err
pipe if it was requested by the caller and it hasn't been closed
by the caller. This simplifies anyone who wants to get a pipe to
the stderr stream for another process.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
run-command.c | 3 +++
run-command.h | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/run-command.c b/run-command.c
index 52f80be..7bf2cd7 100644
--- a/run-command.c
+++ b/run-command.c
@@ -51,6 +51,7 @@ int start_command(struct child_process *cmd)
return -ERR_RUN_COMMAND_PIPE;
}
cmd->err = fderr[0];
+ cmd->close_err = 1;
}
cmd->pid = fork();
@@ -161,6 +162,8 @@ int finish_command(struct child_process *cmd)
close(cmd->in);
if (cmd->close_out)
close(cmd->out);
+ if (cmd->close_err)
+ close(cmd->err);
return wait_or_whine(cmd->pid);
}
diff --git a/run-command.h b/run-command.h
index 1fc781d..705cf2f 100644
--- a/run-command.h
+++ b/run-command.h
@@ -21,6 +21,7 @@ struct child_process {
const char *const *env;
unsigned close_in:1;
unsigned close_out:1;
+ unsigned close_err:1;
unsigned no_stdin:1;
unsigned no_stdout:1;
unsigned no_stderr:1;
--
1.5.4.rc5.1126.g6ba14
reply other threads:[~2008-01-30 6:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080130062202.GC15838@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).