From 0e6efe06ea2dd4029633c9fd98f5fc81049c7db8 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 13 Jul 2018 10:05:25 -0500 Subject: [PATCH] YARN-8515. container-executor can crash with SIGPIPE after nodemanager restart. Contributed by Jim Brennan (cherry picked from commit 17118f446c2387aa796849da8b69a845d9d307d3) --- .../src/main/native/container-executor/impl/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c index a1b5ebc3422..26bd54a5b29 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/main.c @@ -28,6 +28,7 @@ #include #include #include +#include static void display_usage(FILE *stream) { fprintf(stream, @@ -104,6 +105,11 @@ static void open_log_files() { if (ERRORFILE == NULL) { ERRORFILE = stderr; } + + // There may be a process reading from stdout/stderr, and if it + // exits, we will crash on a SIGPIPE when we try to write to them. + // By ignoring SIGPIPE, we can handle the EPIPE instead of crashing. + signal(SIGPIPE, SIG_IGN); } /* Flushes and closes log files */