Pass correct end of readiness notification pipe to subprocess.
authorDavin McCall <davmac@davmac.org>
Sat, 17 Nov 2018 09:56:33 +0000 (09:56 +0000)
committerDavin McCall <davmac@davmac.org>
Sat, 17 Nov 2018 09:56:33 +0000 (09:56 +0000)
src/baseproc-service.cc

index c4371855deb0661097ad3f5ceaef2971c93806f3..22a61a2800a30d024ecd7d49c98d31efe998002d 100644 (file)
@@ -155,16 +155,15 @@ bool base_process_service::start_ps_process(const std::vector<const char *> &cmd
         const char * working_dir_c = nullptr;
         if (! working_dir.empty()) working_dir_c = working_dir.c_str();
         run_child_proc(cmd.data(), working_dir_c, logfile, on_console, pipefd[1], control_socket[1],
-                socket_fd, notify_pipe[0], force_notification_fd, nullptr,  run_as_uid, run_as_gid);
+                socket_fd, notify_pipe[1], force_notification_fd, nullptr,  run_as_uid, run_as_gid);
     }
     else {
         // Parent process
-        bp_sys::close(pipefd[1]); // close the 'other end' fd
-        if (control_socket[1] != -1) {
-            bp_sys::close(control_socket[1]);
-        }
         pid = forkpid;
 
+        bp_sys::close(pipefd[1]); // close the 'other end' fd
+        if (control_socket[1] != -1) bp_sys::close(control_socket[1]);
+        if (notify_pipe[1] != -1) bp_sys::close(notify_pipe[1]);
         notification_fd = notify_pipe[0];
         waiting_for_execstat = true;
         return true;