[PATCH 21/22] run-command: optionally redirect stderr to /dev/null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Sven Verdoolaege <skimo@xxxxxxxxxx>

Signed-off-by: Sven Verdoolaege <skimo@xxxxxxxxxx>
---
 run-command.c |    4 ++++
 run-command.h |    8 +++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/run-command.c b/run-command.c
index d5b8ba2..a620be3 100644
--- a/run-command.c
+++ b/run-command.c
@@ -73,6 +73,9 @@ int start_command(struct child_process *cmd)
 			close(cmd->out);
 		}
 
+		if (cmd->no_stderr)
+			dup_devnull(2);
+
 		if (cmd->dir && chdir(cmd->dir))
 			die("exec %s: cd to %s failed (%s)", cmd->argv[0],
 			    cmd->dir, strerror(errno));
@@ -151,6 +154,7 @@ static void prepare_run_command_v_opt(struct child_process *cmd,
 	cmd->argv = argv;
 	cmd->no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
 	cmd->no_stdout = opt & RUN_COMMAND_NO_STDOUT ? 1 : 0;
+	cmd->no_stderr = opt & RUN_COMMAND_NO_STDERR ? 1 : 0;
 	cmd->git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
 	cmd->stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
 	cmd->clear_git_env = opt & RUN_COMMAND_CLEAR_GIT_ENV ? 1 : 0;
diff --git a/run-command.h b/run-command.h
index e3e897a..85770e0 100644
--- a/run-command.h
+++ b/run-command.h
@@ -21,6 +21,7 @@ struct child_process {
 	unsigned close_out:1;
 	unsigned no_stdin:1;
 	unsigned no_stdout:1;
+	unsigned no_stderr:1;
 	unsigned git_cmd:1; /* if this is to be git sub-command */
 	unsigned stdout_to_stderr:1;
 	unsigned clear_git_env:1;
@@ -32,9 +33,10 @@ int run_command(struct child_process *);
 
 #define RUN_COMMAND_NO_STDIN 		(1 << 0)
 #define RUN_COMMAND_NO_STDOUT 		(1 << 1)
-#define RUN_GIT_CMD			(1 << 2)	/* git sub-command */
-#define RUN_COMMAND_STDOUT_TO_STDERR 	(1 << 3)
-#define RUN_COMMAND_CLEAR_GIT_ENV	(1 << 4)
+#define RUN_COMMAND_NO_STDERR 		(1 << 2)
+#define RUN_GIT_CMD			(1 << 3)	/* git sub-command */
+#define RUN_COMMAND_STDOUT_TO_STDERR 	(1 << 4)
+#define RUN_COMMAND_CLEAR_GIT_ENV	(1 << 5)
 int run_command_v_opt(const char **argv, int opt);
 int run_command_v_opt_cd(const char **argv, int opt, const char *dir);
 
-- 
1.5.2.784.g5532e

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux