From c09519aeab9259cdd4e750db8eaeed670f918458 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sat, 29 Jun 2019 15:34:07 +1000 Subject: [PATCH] Only move fds from force_notify_fd if it is set! --- src/run-child-proc.cc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/run-child-proc.cc b/src/run-child-proc.cc index fdcf137..0d3f802 100644 --- a/src/run-child-proc.cc +++ b/src/run-child-proc.cc @@ -74,26 +74,26 @@ void service_record::run_child_proc(const char * const *args, const char *workin int minfd = (socket_fd == -1) ? 3 : 4; - // Move wpipefd/csfd/socket_fd to another fd if necessary: - if (wpipefd == force_notify_fd) { - if (move_reserved_fd(&wpipefd, minfd) == -1) { - goto failure_out; + if (force_notify_fd != -1) { + // Move wpipefd/csfd/socket_fd to another fd if necessary: + if (wpipefd == force_notify_fd) { + if (move_reserved_fd(&wpipefd, minfd) == -1) { + goto failure_out; + } } - } - if (csfd == force_notify_fd) { - if (move_reserved_fd(&csfd, minfd) == -1) { - goto failure_out; + if (csfd == force_notify_fd) { + if (move_reserved_fd(&csfd, minfd) == -1) { + goto failure_out; + } } - } - if (socket_fd == force_notify_fd) { - // Note that we might move this again later - if (move_reserved_fd(&socket_fd, 0) == -1) { - goto failure_out; + if (socket_fd == force_notify_fd) { + // Note that we might move this again later + if (move_reserved_fd(&socket_fd, 0) == -1) { + goto failure_out; + } } - } - // allocate the forced notification fd, if specified: - if (force_notify_fd != -1) { + // allocate the forced notification fd: if (notify_fd != force_notify_fd) { if (dup2(notify_fd, force_notify_fd) == -1) { goto failure_out; -- 2.25.1