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

[PATCH 3/5] send-pack: isolate sigpipe in demuxer thread

From
Jeff King <peff@peff.net>
Date
Apr 19, 2016, 22:50 UTC
Message-ID
<20160419225016.GC18255@sigill.intra.peff.net>
In-Reply-To
<20160419223945.GA18055@sigill.intra.peff.net>

If we get an error from pack-objects, we may exit send_pack() early, before reading the server's status response. In such a case, we may racily see SIGPIPE from our async demuxer (which is trying to write that status back to us), and we'd prefer to continue pushing the error up the call stack, rather than taking down the whole process with signal death.

This is safe to do because our demuxer just calls recv_sideband, whose data writes are all done with write_or_die(), which will notice SIGPIPE.

We do also write sideband 2 to stderr, and we would no longer die on SIGPIPE there (if it were piped in the first place, and if the piped program went away). But that's probably a good thing, as it likewise should not abort the push process at all (neither immediately by signal, nor eventually by reporting failure back to the main thread).

Signed-off-by: Jeff King <peff@peff.net>
---
 send-pack.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/send-pack.c b/send-pack.c
index fc27db6..37ee04e 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -518,6 +518,7 @@ int send_pack(struct send_pack_args *args,
 		demux.proc = sideband_demux;
 		demux.data = fd;
 		demux.out = -1;
+		demux.isolate_sigpipe = 1;
 		if (start_async(&demux))
 			die("send-pack: unable to fork off sideband demultiplexer");
 		in = demux.out;
-- 
2.8.1.512.g4e0a533
Previous: Jeff KingNext: Jeff King
Message 6 of 10 in “fix deadlock in git-push”
  1. 0/5 fix deadlock in git-pushJeff King, Apr 19, 2016
  2. 1/5 send-pack: close demux pipe before finishing async processJeff King, Apr 19, 2016
  3. 2/5 run-command: teach async threads to ignore SIGPIPEJeff King, Apr 19, 2016
  4. Johannes SixtApr 21, 2016
  5. Jeff KingApr 21, 2016
  6. 3/5 send-pack: isolate sigpipe in demuxer threadJeff King, Apr 19, 2016
  7. 4/5 fetch-pack: isolate sigpipe in demuxer threadJeff King, Apr 19, 2016
  8. 5/5 t5504: drop sigpipe=ok from push testsJeff King, Apr 19, 2016
  9. Junio C HamanoApr 20, 2016
  10. Jeff KingApr 20, 2016

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.