From: Davin McCall Date: Sat, 29 Jun 2019 05:34:07 +0000 (+1000) Subject: Only move fds from force_notify_fd if it is set! X-Git-Tag: v0.5.2~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c09519aeab9259cdd4e750db8eaeed670f918458;p=oweals%2Fdinit.git Only move fds from force_notify_fd if it is set! --- 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;