@@ -641,20 +641,6 @@ struct bufsize {
641
641
int bufsiz = 0 ;
642
642
};
643
643
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
-
658
644
/* !
659
645
* Base class for all arguments involving string value.
660
646
*/
@@ -929,7 +915,6 @@ struct ArgumentDeducer
929
915
void set_option (input&& inp);
930
916
void set_option (output&& out);
931
917
void set_option (error&& err);
932
- void set_option (close_fds&& cfds);
933
918
934
919
private:
935
920
Popen* popen_ = nullptr ;
@@ -1255,8 +1240,6 @@ class Popen
1255
1240
std::future<void > cleanup_future_;
1256
1241
#endif
1257
1242
1258
- bool close_fds_ = false ;
1259
-
1260
1243
std::string exe_name_;
1261
1244
std::string cwd_;
1262
1245
env_map_t env_;
@@ -1572,10 +1555,6 @@ namespace detail {
1572
1555
if (err.rd_ch_ != -1 ) popen_->stream_ .err_read_ = err.rd_ch_ ;
1573
1556
}
1574
1557
1575
- inline void ArgumentDeducer::set_option (close_fds&& cfds) {
1576
- popen_->close_fds_ = cfds.close_all ;
1577
- }
1578
-
1579
1558
1580
1559
inline void Child::execute_child () {
1581
1560
#ifndef __USING_WINDOWS__
@@ -1622,17 +1601,6 @@ namespace detail {
1622
1601
if (stream.err_write_ != -1 && stream.err_write_ > 2 )
1623
1602
close (stream.err_write_ );
1624
1603
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
-
1636
1604
// Change the working directory if provided
1637
1605
if (parent_->cwd_ .length ()) {
1638
1606
sys_ret = chdir (parent_->cwd_ .c_str ());
0 commit comments