git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/6] send-pack: report signal death of pack-objects

From
Jeff King <peff@peff.net>
Date
Mar 7, 2017, 13:39 UTC
Message-ID
<20170307133948.x3w6nufae7tbgeka@sigill.intra.peff.net>
In-Reply-To
<20170307133437.qee2jtynbiwf6uzr@sigill.intra.peff.net>

If our pack-objects sub-process dies of a signal, then it likely didn't have a chance to write anything useful to stderr. The user may be left scratching their head why the push failed. Let's detect this situation and write something to stderr.

Signed-off-by: Jeff King <peff@peff.net>
---
We could drop the SIGPIPE special-case, but I think it's just noise
after the unpack-status fix in the previous commit.
 send-pack.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/send-pack.c b/send-pack.c
index e15232739..d2d2a49a0 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -72,6 +72,7 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
 	struct child_process po = CHILD_PROCESS_INIT;
 	FILE *po_in;
 	int i;
+	int rc;
 
 	i = 4;
 	if (args->use_thin_pack)
@@ -125,8 +126,20 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
 		po.out = -1;
 	}
 
-	if (finish_command(&po))
+	rc = finish_command(&po);
+	if (rc) {
+		/*
+		 * For a normal non-zero exit, we assume pack-objects wrote
+		 * something useful to stderr. For death by signal, though,
+		 * we should mention it to the user. The exception is SIGPIPE
+		 * (141), because that's a normal occurence if the remote end
+		 * hangs up (and we'll report that by trying to read the unpack
+		 * status).
+		 */
+		if (rc > 128 && rc != 141)
+			error("pack-objects died of signal %d", rc - 128);
 		return -1;
+	}
 	return 0;
 }
 
-- 
2.12.0.429.gde83c8049
Previous: Jeff KingNext: Jeff King
Message 4 of 12 in “deadlock regression in v2.11.0 with failed mkdtemp”
  1. 0/6 deadlock regression in v2.11.0 with failed mkdtempJeff King, Mar 7, 2017
  2. 1/6 receive-pack: fix deadlock when we cannot create tmpdirJeff King, Mar 7, 2017
  3. 2/6 send-pack: extract parsing of "unpack" responseJeff King, Mar 7, 2017
  4. 6/6 send-pack: report signal death of pack-objectsJeff King, Mar 7, 2017
  5. 5/6 send-pack: read "unpack" status even on pack-objects failureJeff King, Mar 7, 2017
  6. 4/6 send-pack: improve unpack-status error messagesJeff King, Mar 7, 2017
  7. Junio C HamanoMar 7, 2017
  8. Jeff KingMar 8, 2017
  9. Junio C HamanoMar 8, 2017
  10. Jeff KingMar 7, 2017
  11. 3/6 send-pack: use skip_prefix for parsing unpack statusJeff King, Mar 7, 2017
  12. Horst SchirmeierMar 8, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.