From b992fe104ecde5a362a31d610de96518f398d5c0 Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Sun, 16 Oct 2016 16:20:27 -0700 Subject: run-command: move check_pipe() from write_or_die to run_command Move check_pipe() to run_command and make it public. This is necessary to call the function from pkt-line in a subsequent patch. While at it, make async_exit() static to run_command.c as it is no longer used from outside. Signed-off-by: Lars Schneider Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- run-command.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'run-command.c') diff --git a/run-command.c b/run-command.c index 5a4dbb66d7..326936273d 100644 --- a/run-command.c +++ b/run-command.c @@ -634,7 +634,7 @@ int in_async(void) return !pthread_equal(main_thread, pthread_self()); } -void NORETURN async_exit(int code) +static void NORETURN async_exit(int code) { pthread_exit((void *)(intptr_t)code); } @@ -684,13 +684,26 @@ int in_async(void) return process_is_async; } -void NORETURN async_exit(int code) +static void NORETURN async_exit(int code) { exit(code); } #endif +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... */ + exit(141); + } +} + int start_async(struct async *async) { int need_in, need_out; -- cgit v1.2.1