From e1bb49c2948627a0cd2ddadf255b9312ddd70d45 Mon Sep 17 00:00:00 2001 From: Sylvain Joubert Date: Wed, 22 Jul 2026 11:09:41 +0200 Subject: [PATCH] Make basic_process default constructor =delete'd The basic_process defaulted default constructor fails to compiles and since it is *NOT* expected to be default constructible this marks it as such and removes the misleading comment Fixes #562 --- doc/reference/process.adoc | 12 +++++------- include/boost/process/v2/process.hpp | 28 +++++++++++++--------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/doc/reference/process.adoc b/doc/reference/process.adoc index 91cc22250..4cc08e628 100644 --- a/doc/reference/process.adoc +++ b/doc/reference/process.adoc @@ -35,9 +35,7 @@ struct basic_process typedef basic_process other; }; - /** An empty process is similar to a default constructed thread. It holds an empty - handle and is a place holder for a process that is to be launched later. */ - basic_process() = default; + basic_process() = delete; basic_process(const basic_process&) = delete; basic_process& operator=(const basic_process&) = delete; @@ -59,7 +57,7 @@ struct basic_process const filesystem::path& exe, std::initializer_list args, Inits&&... inits); - + // Construct a child from a property list and launch it using the default launcher.. template explicit basic_process( @@ -147,11 +145,11 @@ struct basic_process // Get the id of the process; pid_type id() const; - // The native handle of the process. + // The native handle of the process. /** This might be undefined on posix systems that only support signals */ native_exit_code_type native_exit_code() const; - // Checks if the current process is running. + // Checks if the current process is running. /* If it has already completed the exit code will be stored internally * and can be obtained by calling `exit_code. */ @@ -161,7 +159,7 @@ struct basic_process // Check if the process is referring to an existing process. /** Note that this might be a process that already exited.*/ bool is_open() const; - + // Asynchronously wait for the process to exit and deliver the native exit-code in the completion handler. template > diff --git a/include/boost/process/v2/process.hpp b/include/boost/process/v2/process.hpp index 789539e36..db227ebcd 100644 --- a/include/boost/process/v2/process.hpp +++ b/include/boost/process/v2/process.hpp @@ -64,9 +64,7 @@ struct basic_process typedef basic_process other; }; - /** An empty process is similar to a default constructed thread. It holds an empty - handle and is a place holder for a process that is to be launched later. */ - basic_process() = default; + basic_process() = delete; basic_process(const basic_process&) = delete; basic_process& operator=(const basic_process&) = delete; @@ -95,7 +93,7 @@ struct basic_process : basic_process(default_process_launcher()(std::move(executor), exe, args, std::forward(inits)...)) { } - + /// Construct a child from a property list and launch it using the default launcher.. template explicit basic_process( @@ -112,7 +110,7 @@ struct basic_process explicit basic_process( ExecutionContext & context, typename std::enable_if< - std::is_convertible::value, const filesystem::path&>::type exe, std::initializer_list args, @@ -126,7 +124,7 @@ struct basic_process explicit basic_process( ExecutionContext & context, typename std::enable_if< - std::is_convertible::value, const filesystem::path&>::type exe, Args&& args, Inits&&... inits) @@ -157,7 +155,7 @@ struct basic_process template explicit basic_process(ExecutionContext & context, pid_type pid, native_handle_type native_handle, typename std::enable_if< - std::is_convertible::value, void *>::type = nullptr) : process_handle_(context.get_executor(), pid, native_handle) {} @@ -165,7 +163,7 @@ struct basic_process template explicit basic_process(ExecutionContext & context, typename std::enable_if< - std::is_convertible::value, void *>::type = nullptr) : process_handle_(context.get_executor()) {} @@ -226,7 +224,7 @@ struct basic_process /// Send the process a signal requesting it to resume. This may rely on undocumented functions. void resume(error_code &ec) { - process_handle_.resume(ec); + process_handle_.resume(ec); } /// Send the process a signal requesting it to resume. This may rely on undocumented functions. @@ -290,14 +288,14 @@ struct basic_process /// Get the id of the process; pid_type id() const {return process_handle_.id();} - /// The native handle of the process. + /// The native handle of the process. /** This might be undefined on posix systems that only support signals */ native_exit_code_type native_exit_code() const { return exit_status_; } - /// Checks if the current process is running. - /** If it has already completed the exit code will be stored internally + /// Checks if the current process is running. + /** If it has already completed the exit code will be stored internally * and can be obtained by calling `exit_code. */ bool running() @@ -326,11 +324,11 @@ struct basic_process exit_status_ = exit_code; return r; } - + /// Check if the process is referring to an existing process. /** Note that this might be a process that already exited.*/ bool is_open() const { return process_handle_.is_open(); } - + private: @@ -340,7 +338,7 @@ struct basic_process basic_process_handle process_handle_; native_exit_code_type exit_status_{detail::still_active}; - + struct async_wait_op_ { basic_process_handle & handle;