[PATCH 1/4] teach wait_or_whine a "quiet" mode

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

 



The wait_or_whine function will complain to stderr in a few
cases:

  1. We fail to actually waitpid() correctly.

  2. The child died of a signal.

  3. The child returned exit code 127, indicating a missing
     command to exec after forking.

We already have a silent_exec_failure flag to silence (3).
Let's convert that into a "quiet" flag to also silence (2).
This shouldn't result in signal failure being silent for
existing users of silent_exec_failure, since they already
will need to be checking the return code and complaining for
the case of a non-zero exit code.

For (1), it probably makes sense to always complain about a
failure to correctly wait, so let's not quiet that.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 run-command.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/run-command.c b/run-command.c
index 0d95340..0d5626a 100644
--- a/run-command.c
+++ b/run-command.c
@@ -240,7 +240,7 @@ fail_pipe:
 	return 0;
 }
 
-static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
+static int wait_or_whine(pid_t pid, const char *argv0, int quiet)
 {
 	int status, code = -1;
 	pid_t waiting;
@@ -256,7 +256,8 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
 		error("waitpid is confused (%s)", argv0);
 	} else if (WIFSIGNALED(status)) {
 		code = WTERMSIG(status);
-		error("%s died of signal %d", argv0, code);
+		if (!quiet)
+			error("%s died of signal %d", argv0, code);
 		/*
 		 * This return value is chosen so that code & 0xff
 		 * mimics the exit code that a POSIX shell would report for
@@ -271,7 +272,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
 		if (code == 127) {
 			code = -1;
 			failed_errno = ENOENT;
-			if (!silent_exec_failure)
+			if (!quiet)
 				error("cannot run %s: %s", argv0,
 					strerror(ENOENT));
 		}
-- 
1.7.4.13.g8566c

--
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]