path: root/run-command.h
diff options
authorJeff King <>2016-04-19 22:49:41 (GMT)
committerJunio C Hamano <>2016-04-20 20:33:53 (GMT)
commitc792d7b6cebe302d6e0377d9d983608309bcd775 (patch)
tree8618b0d611b9c90420cb52732fe0cf3c03a6f0bd /run-command.h
parent739cf49161db01855c03c283f6aa3f5341a1ab36 (diff)
run-command: teach async threads to ignore SIGPIPE
Async processes can be implemented as separate forked processes, or as threads (depending on the NO_PTHREADS setting). In the latter case, if an async thread gets SIGPIPE, it takes down the whole process. This is obviously bad if the main process was not otherwise going to die, but even if we were going to die, it means the main process does not have a chance to report a useful error message. There's also the small matter that forked async processes will not take the main process down on a signal, meaning git will behave differently depending on the NO_PTHREADS setting. This patch fixes it by adding a new flag to "struct async" to block SIGPIPE just in the async thread. In theory, this should always be on (which makes async threads behave more like async processes), but we would first want to make sure that each async process we spawn is careful about checking return codes from write() and would not spew endlessly into a dead pipe. So let's start with it as optional, and we can enable it for specific sites in future patches. The natural name for this option would be "ignore_sigpipe", since that's what it does for the threaded case. But since that name might imply that we are ignoring it in all cases (including the separate-process one), let's call it "isolate_sigpipe". What we are really asking for is isolation. I.e., not to have our main process taken down by signals spawned by the async process. How that is implemented is up to the run-command code. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'run-command.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/run-command.h b/run-command.h
index c0969c7..a3043b1 100644
--- a/run-command.h
+++ b/run-command.h
@@ -116,6 +116,7 @@ struct async {
int proc_in;
int proc_out;
+ int isolate_sigpipe;
int start_async(struct async *async);