[PATCH v8 03/11] run-command: move check_pipe() from write_or_die to run_command
From: <hidden>
Date: 2016-09-20 19:03:06
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Lars Schneider <redacted> Move check_pipe() to run_command and make it public. This is necessary to call the function from pkt-line in a subsequent patch. Signed-off-by: Lars Schneider <redacted> --- run-command.c | 13 +++++++++++++ run-command.h | 2 ++ write_or_die.c | 13 ------------- 3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/run-command.c b/run-command.c
index 5a4dbb6..b72f6d1 100644
--- a/run-command.c
+++ b/run-command.c@@ -6,6 +6,19 @@ #include "thread-utils.h" #include "strbuf.h" +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); + } +} + void child_process_init(struct child_process *child) { memset(child, 0, sizeof(*child));
diff --git a/run-command.h b/run-command.h
index 5066649..e7c5f71 100644
--- a/run-command.h
+++ b/run-command.h@@ -54,6 +54,8 @@ int finish_command(struct child_process *); int finish_command_in_signal(struct child_process *); int run_command(struct child_process *); +void check_pipe(int err); + /* * Returns the path to the hook file, or NULL if the hook is missing * or disabled. Note that this points to static storage that will be
diff --git a/write_or_die.c b/write_or_die.c
index 0734432..eab8c8d 100644
--- a/write_or_die.c
+++ b/write_or_die.c@@ -1,19 +1,6 @@ #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... */ - exit(141); - } -} - /* * Some cases use stdio, but want to flush after the write * to get error handling (and to get better interactive
--
2.10.0