Commit 80d5f1347d70550d49d95b6420ca27877d1221e8

Stefan Sperling 2018-11-11T12:59:22

don't be noisy on stderr when Ctrl-C is hit

diff --git a/got/got.c b/got/got.c
index b0622d7..6b95775 100644
--- a/got/got.c
+++ b/got/got.c
@@ -143,7 +143,7 @@ main(int argc, char *argv[])
 			got_commands[i].cmd_usage();
 
 		error = got_commands[i].cmd_main(argc, argv);
-		if (error) {
+		if (error && !(sigint_received || sigpipe_received)) {
 			fprintf(stderr, "%s: %s\n", getprogname(), error->msg);
 			return 1;
 		}
diff --git a/libexec/got-read-blob/got-read-blob.c b/libexec/got-read-blob/got-read-blob.c
index d33d70d..d45817f 100644
--- a/libexec/got-read-blob/got-read-blob.c
+++ b/libexec/got-read-blob/got-read-blob.c
@@ -158,9 +158,10 @@ done:
 
 	imsg_clear(&ibuf);
 	if (err) {
-		fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
-		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE)
+		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE) {
+			fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
 			got_privsep_send_error(&ibuf, err);
+		}
 	}
 	close(GOT_IMSG_FD_CHILD);
 	return err ? 1 : 0;
diff --git a/libexec/got-read-commit/got-read-commit.c b/libexec/got-read-commit/got-read-commit.c
index 56aac6a..9ebca90 100644
--- a/libexec/got-read-commit/got-read-commit.c
+++ b/libexec/got-read-commit/got-read-commit.c
@@ -174,9 +174,10 @@ done:
 
 	imsg_clear(&ibuf);
 	if (err) {
-		fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
-		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE)
+		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE) {
+			fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
 			got_privsep_send_error(&ibuf, err);
+		}
 	}
 	close(GOT_IMSG_FD_CHILD);
 	return err ? 1 : 0;
diff --git a/libexec/got-read-object/got-read-object.c b/libexec/got-read-object/got-read-object.c
index 8f4ccd3..2d71593 100644
--- a/libexec/got-read-object/got-read-object.c
+++ b/libexec/got-read-object/got-read-object.c
@@ -219,9 +219,10 @@ done:
 
 	imsg_clear(&ibuf);
 	if (err) {
-		fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
-		if(!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE)
+		if(!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE) {
+			fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
 			got_privsep_send_error(&ibuf, err);
+		}
 	}
 	close(GOT_IMSG_FD_CHILD);
 	return err ? 1 : 0;
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index debf114..24f359a 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -507,9 +507,10 @@ main(int argc, char *argv[])
 	got_object_cache_close(&objcache);
 	imsg_clear(&ibuf);
 	if (err) {
-		fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
-		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE)
+		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE) {
+			fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
 			got_privsep_send_error(&ibuf, err);
+		}
 	}
 	close(GOT_IMSG_FD_CHILD);
 	return err ? 1 : 0;
diff --git a/libexec/got-read-tree/got-read-tree.c b/libexec/got-read-tree/got-read-tree.c
index 176d429..9030954 100644
--- a/libexec/got-read-tree/got-read-tree.c
+++ b/libexec/got-read-tree/got-read-tree.c
@@ -172,9 +172,10 @@ done:
 
 	imsg_clear(&ibuf);
 	if (err) {
-		fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
-		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE)
+		if (!sigint_received && err->code != GOT_ERR_PRIVSEP_PIPE) {
+			fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
 			got_privsep_send_error(&ibuf, err);
+		}
 	}
 	close(GOT_IMSG_FD_CHILD);
 	return err ? 1 : 0;