Skip to content

Commit 79c3036

Browse files
committed
remove unneeded close_fds option from cpp-subprocess
1 parent 62db8f8 commit 79c3036

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

src/util/subprocess.hpp

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

644-
/*!
645-
* Option to close all file descriptors
646-
* when the child process is spawned.
647-
* The close fd list does not include
648-
* input/output/error if they are explicitly
649-
* set as part of the Popen arguments.
650-
*
651-
* Default value is false.
652-
*/
653-
struct close_fds {
654-
explicit close_fds(bool c): close_all(c) {}
655-
bool close_all = false;
656-
};
657-
658644
/*!
659645
* Base class for all arguments involving string value.
660646
*/
@@ -929,7 +915,6 @@ struct ArgumentDeducer
929915
void set_option(input&& inp);
930916
void set_option(output&& out);
931917
void set_option(error&& err);
932-
void set_option(close_fds&& cfds);
933918

934919
private:
935920
Popen* popen_ = nullptr;
@@ -1255,8 +1240,6 @@ class Popen
12551240
std::future<void> cleanup_future_;
12561241
#endif
12571242

1258-
bool close_fds_ = false;
1259-
12601243
std::string exe_name_;
12611244
std::string cwd_;
12621245
env_map_t env_;
@@ -1572,10 +1555,6 @@ namespace detail {
15721555
if (err.rd_ch_ != -1) popen_->stream_.err_read_ = err.rd_ch_;
15731556
}
15741557

1575-
inline void ArgumentDeducer::set_option(close_fds&& cfds) {
1576-
popen_->close_fds_ = cfds.close_all;
1577-
}
1578-
15791558

15801559
inline void Child::execute_child() {
15811560
#ifndef __USING_WINDOWS__
@@ -1622,17 +1601,6 @@ namespace detail {
16221601
if (stream.err_write_ != -1 && stream.err_write_ > 2)
16231602
close(stream.err_write_);
16241603

1625-
// Close all the inherited fd's except the error write pipe
1626-
if (parent_->close_fds_) {
1627-
int max_fd = sysconf(_SC_OPEN_MAX);
1628-
if (max_fd == -1) throw OSError("sysconf failed", errno);
1629-
1630-
for (int i = 3; i < max_fd; i++) {
1631-
if (i == err_wr_pipe_) continue;
1632-
close(i);
1633-
}
1634-
}
1635-
16361604
// Change the working directory if provided
16371605
if (parent_->cwd_.length()) {
16381606
sys_ret = chdir(parent_->cwd_.c_str());

0 commit comments

Comments
 (0)