summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2b26e0e)
raw | patch | inline | side by side (parent: 2b26e0e)
author | Shawn O. Pearce <spearce@spearce.org> | |
Fri, 5 Feb 2010 20:57:37 +0000 (12:57 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 6 Feb 2010 04:57:16 +0000 (20:57 -0800) |
Like .out, .err may now be set to a file descriptor > 0, which
is a writable pipe/socket/file that the child's stderr will be
redirected into.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
is a writable pipe/socket/file that the child's stderr will be
redirected into.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/api-run-command.txt | patch | blob | history | |
run-command.c | patch | blob | history | |
run-command.h | patch | blob | history |
diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt
index b26c28133c143b23acf28fc1a3a06d16c10c65f8..a1280dd83755fc55ca13940b55ba37a64595b7f8 100644 (file)
.in: The FD must be readable; it becomes child's stdin.
.out: The FD must be writable; it becomes child's stdout.
- .err > 0 is not supported.
+ .err: The FD must be writable; it becomes child's stderr.
The specified FD is closed by start_command(), even if it fails to
run the sub-process!
diff --git a/run-command.c b/run-command.c
index cf2d8f7fae1356e50736cb9d599625df79738a2a..bfd231243d2293b1803fc3c3614f67279e959362 100644 (file)
--- a/run-command.c
+++ b/run-command.c
else if (need_err) {
dup2(fderr[1], 2);
close_pair(fderr);
+ } else if (cmd->err > 1) {
+ dup2(cmd->err, 2);
+ close(cmd->err);
}
if (cmd->no_stdout)
} else if (need_err) {
s2 = dup(2);
dup2(fderr[1], 2);
+ } else if (cmd->err > 2) {
+ s2 = dup(2);
+ dup2(cmd->err, 2);
}
if (cmd->no_stdout) {
if (need_err)
close(fderr[1]);
+ else if (cmd->err)
+ close(cmd->err);
return 0;
}
diff --git a/run-command.h b/run-command.h
index fb342090e3cac49f41689f9610bfe2d6c87c87c1..a29171adae9903420d29bdcdd4acb2191e683f75 100644 (file)
--- a/run-command.h
+++ b/run-command.h
* - Specify > 0 to set a channel to a particular FD as follows:
* .in: a readable FD, becomes child's stdin
* .out: a writable FD, becomes child's stdout/stderr
- * .err > 0 not supported
+ * .err: a writable FD, becomes child's stderr
* The specified FD is closed by start_command(), even in case
* of errors!
*/