summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--run-command.c10
-rw-r--r--run-command.h1
-rw-r--r--write_or_die.c4
3 files changed, 15 insertions, 0 deletions
diff --git a/run-command.c b/run-command.c
index 13fa452e8c..3add1d66ac 100644
--- a/run-command.c
+++ b/run-command.c
@@ -633,6 +633,11 @@ int in_async(void)
return !pthread_equal(main_thread, pthread_self());
}
+void NORETURN async_exit(int code)
+{
+ pthread_exit((void *)(intptr_t)code);
+}
+
#else
static struct {
@@ -678,6 +683,11 @@ int in_async(void)
return process_is_async;
}
+void NORETURN async_exit(int code)
+{
+ exit(code);
+}
+
#endif
int start_async(struct async *async)
diff --git a/run-command.h b/run-command.h
index 12bb26c2a6..c0969c7695 100644
--- a/run-command.h
+++ b/run-command.h
@@ -121,5 +121,6 @@ struct async {
int start_async(struct async *async);
int finish_async(struct async *async);
int in_async(void);
+void NORETURN async_exit(int code);
#endif
diff --git a/write_or_die.c b/write_or_die.c
index e7afe7a295..49e80aa222 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -1,8 +1,12 @@
#include "cache.h"
+#include "run-command.h"
static void check_pipe(int err)
{
if (err == EPIPE) {
+ if (in_async())
+ async_exit(141);
+
signal(SIGPIPE, SIG_DFL);
raise(SIGPIPE);
/* Should never happen, but just in case... */