Skip to content

Commit 80d008c

Browse files
committed
remove unneeded defer_spawn option from cpp-subprocess
For our use-case, there doesn't seem to be any need for this.
1 parent cececad commit 80d008c

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

src/util/subprocess.hpp

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -641,16 +641,6 @@ struct bufsize {
641641
int bufsiz = 0;
642642
};
643643

644-
/*!
645-
* Option to defer spawning of the child process
646-
* till `Popen::start_process` API is called.
647-
* Default value is false.
648-
*/
649-
struct defer_spawn {
650-
explicit defer_spawn(bool d): defer(d) {}
651-
bool defer = false;
652-
};
653-
654644
/*!
655645
* Option to close all file descriptors
656646
* when the child process is spawned.
@@ -947,7 +937,6 @@ struct ArgumentDeducer
947937
void set_option(cwd&& cwdir);
948938
void set_option(bufsize&& bsiz);
949939
void set_option(environment&& env);
950-
void set_option(defer_spawn&& defer);
951940
void set_option(input&& inp);
952941
void set_option(output&& out);
953942
void set_option(error&& err);
@@ -1153,8 +1142,6 @@ class Streams
11531142
in case of redirection. See piping examples.
11541143
*12. error() - Get the error channel/File pointer. Usually used
11551144
in case of redirection.
1156-
*13. start_process() - Start the child process. Only to be used when
1157-
* `defer_spawn` option was provided in Popen constructor.
11581145
*/
11591146
class Popen
11601147
{
@@ -1172,7 +1159,7 @@ class Popen
11721159
// Setup the communication channels of the Popen class
11731160
stream_.setup_comm_channels();
11741161

1175-
if (!defer_process_start_) execute_process();
1162+
execute_process();
11761163
}
11771164

11781165
template <typename... Args>
@@ -1184,7 +1171,7 @@ class Popen
11841171
// Setup the communication channels of the Popen class
11851172
stream_.setup_comm_channels();
11861173

1187-
if (!defer_process_start_) execute_process();
1174+
execute_process();
11881175
}
11891176

11901177
template <typename... Args>
@@ -1195,7 +1182,7 @@ class Popen
11951182
// Setup the communication channels of the Popen class
11961183
stream_.setup_comm_channels();
11971184

1198-
if (!defer_process_start_) execute_process();
1185+
execute_process();
11991186
}
12001187

12011188
/*
@@ -1207,8 +1194,6 @@ class Popen
12071194
}
12081195
*/
12091196

1210-
void start_process() noexcept(false);
1211-
12121197
int pid() const noexcept { return child_pid_; }
12131198

12141199
int retcode() const noexcept { return retcode_; }
@@ -1282,7 +1267,6 @@ class Popen
12821267
std::future<void> cleanup_future_;
12831268
#endif
12841269

1285-
bool defer_process_start_ = false;
12861270
bool close_fds_ = false;
12871271
bool session_leader_ = false;
12881272

@@ -1323,20 +1307,6 @@ inline void Popen::populate_c_argv()
13231307
cargv_.push_back(nullptr);
13241308
}
13251309

1326-
inline void Popen::start_process() noexcept(false)
1327-
{
1328-
// The process was started/tried to be started
1329-
// in the constructor itself.
1330-
// For explicitly calling this API to start the
1331-
// process, 'defer_spawn' argument must be set to
1332-
// true in the constructor.
1333-
if (!defer_process_start_) {
1334-
assert (0);
1335-
return;
1336-
}
1337-
execute_process();
1338-
}
1339-
13401310
inline int Popen::wait() noexcept(false)
13411311
{
13421312
#ifdef __USING_WINDOWS__
@@ -1594,10 +1564,6 @@ namespace detail {
15941564
popen_->env_ = std::move(env.env_);
15951565
}
15961566

1597-
inline void ArgumentDeducer::set_option(defer_spawn&& defer) {
1598-
popen_->defer_process_start_ = defer.defer;
1599-
}
1600-
16011567
inline void ArgumentDeducer::set_option(session_leader&& sleader) {
16021568
popen_->session_leader_ = sleader.leader_;
16031569
}

0 commit comments

Comments
 (0)