remove unneeded defer_spawn option from cpp-subprocess

For our use-case, there doesn't seem to be any need for this.
This commit is contained in:
Sebastian Falbesoner 2024-04-13 11:43:02 +02:00
parent cececad7b2
commit 80d008c66d
1 changed files with 3 additions and 37 deletions

View File

@ -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 <typename... Args>
@ -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 <typename... Args>
@ -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<void> 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_;
}