From 80d008c66d00d3496cd8549daee6775cf2c6b782 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sat, 13 Apr 2024 11:43:02 +0200 Subject: [PATCH] remove unneeded defer_spawn option from cpp-subprocess For our use-case, there doesn't seem to be any need for this. --- src/util/subprocess.hpp | 40 +++------------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/src/util/subprocess.hpp b/src/util/subprocess.hpp index 1a98be3e1d..dd0789b72c 100644 --- a/src/util/subprocess.hpp +++ b/src/util/subprocess.hpp @@ -641,16 +641,6 @@ struct bufsize { int bufsiz = 0; }; -/*! - * Option to defer spawning of the child process - * till `Popen::start_process` API is called. - * Default value is false. - */ -struct defer_spawn { - explicit defer_spawn(bool d): defer(d) {} - bool defer = false; -}; - /*! * Option to close all file descriptors * when the child process is spawned. @@ -947,7 +937,6 @@ struct ArgumentDeducer void set_option(cwd&& cwdir); void set_option(bufsize&& bsiz); void set_option(environment&& env); - void set_option(defer_spawn&& defer); void set_option(input&& inp); void set_option(output&& out); void set_option(error&& err); @@ -1153,8 +1142,6 @@ private: in case of redirection. See piping examples. *12. error() - Get the error channel/File pointer. Usually used in case of redirection. - *13. start_process() - Start the child process. Only to be used when - * `defer_spawn` option was provided in Popen constructor. */ class Popen { @@ -1172,7 +1159,7 @@ public: // Setup the communication channels of the Popen class stream_.setup_comm_channels(); - if (!defer_process_start_) execute_process(); + execute_process(); } template @@ -1184,7 +1171,7 @@ public: // Setup the communication channels of the Popen class stream_.setup_comm_channels(); - if (!defer_process_start_) execute_process(); + execute_process(); } template @@ -1195,7 +1182,7 @@ public: // Setup the communication channels of the Popen class stream_.setup_comm_channels(); - if (!defer_process_start_) execute_process(); + execute_process(); } /* @@ -1207,8 +1194,6 @@ public: } */ - void start_process() noexcept(false); - int pid() const noexcept { return child_pid_; } int retcode() const noexcept { return retcode_; } @@ -1282,7 +1267,6 @@ private: std::future cleanup_future_; #endif - bool defer_process_start_ = false; bool close_fds_ = false; bool session_leader_ = false; @@ -1323,20 +1307,6 @@ inline void Popen::populate_c_argv() cargv_.push_back(nullptr); } -inline void Popen::start_process() noexcept(false) -{ - // The process was started/tried to be started - // in the constructor itself. - // For explicitly calling this API to start the - // process, 'defer_spawn' argument must be set to - // true in the constructor. - if (!defer_process_start_) { - assert (0); - return; - } - execute_process(); -} - inline int Popen::wait() noexcept(false) { #ifdef __USING_WINDOWS__ @@ -1594,10 +1564,6 @@ namespace detail { popen_->env_ = std::move(env.env_); } - inline void ArgumentDeducer::set_option(defer_spawn&& defer) { - popen_->defer_process_start_ = defer.defer; - } - inline void ArgumentDeducer::set_option(session_leader&& sleader) { popen_->session_leader_ = sleader.leader_; }