From 4296fec7f50145e2a307f3db7ae22984713976a7 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 7 Mar 2022 17:07:49 -0500 Subject: [PATCH] process: simplify uv__write_int calls (#3519) --- src/unix/process.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/unix/process.c b/src/unix/process.c index 270d5287..1157006d 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -216,16 +216,14 @@ static void uv__write_int(int fd, int val) { n = write(fd, &val, sizeof(val)); while (n == -1 && errno == EINTR); - if (n == -1 && errno == EPIPE) - return; /* parent process has quit */ - - assert(n == sizeof(val)); + /* The write might have failed (e.g. if the parent process has died), + * but we have nothing left but to _exit ourself now too. */ + _exit(127); } static void uv__write_errno(int error_fd) { uv__write_int(error_fd, UV__ERR(errno)); - _exit(127); } @@ -284,10 +282,8 @@ static void uv__process_child_init(const uv_process_options_t* options, uv__write_errno(error_fd); #ifndef F_DUPFD_CLOEXEC /* POSIX 2008 */ n = uv__cloexec(pipes[fd][1], 1); - if (n) { + if (n) uv__write_int(error_fd, n); - _exit(127); - } #endif } @@ -313,10 +309,8 @@ static void uv__process_child_init(const uv_process_options_t* options, if (fd == use_fd) { if (close_fd == -1) { n = uv__cloexec(use_fd, 0); - if (n) { + if (n) uv__write_int(error_fd, n); - _exit(127); - } } } else { @@ -368,7 +362,6 @@ static void uv__process_child_init(const uv_process_options_t* options, #endif uv__write_errno(error_fd); - abort(); } #endif