mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
remove unneeded preexec function option from cpp-subprocess
We don't seem to ever need this, so remove it.
This commit is contained in:
parent
633e45b2e2
commit
cececad7b2
1 changed files with 0 additions and 50 deletions
|
@ -845,44 +845,6 @@ struct error
|
||||||
int wr_ch_ = -1;
|
int wr_ch_ = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Impoverished, meager, needy, truly needy
|
|
||||||
// version of type erasure to store function pointers
|
|
||||||
// needed to provide the functionality of preexec_func
|
|
||||||
// ATTN: Can be used only to execute functions with no
|
|
||||||
// arguments and returning void.
|
|
||||||
// Could have used more efficient methods, ofcourse, but
|
|
||||||
// that won't yield me the consistent syntax which I am
|
|
||||||
// aiming for. If you know, then please do let me know.
|
|
||||||
|
|
||||||
class preexec_func
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
preexec_func() {}
|
|
||||||
|
|
||||||
template <typename Func>
|
|
||||||
explicit preexec_func(Func f): holder_(new FuncHolder<Func>(std::move(f)))
|
|
||||||
{}
|
|
||||||
|
|
||||||
void operator()() {
|
|
||||||
(*holder_)();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct HolderBase {
|
|
||||||
virtual void operator()() const = 0;
|
|
||||||
virtual ~HolderBase(){};
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
struct FuncHolder: HolderBase {
|
|
||||||
FuncHolder(T func): func_(std::move(func)) {}
|
|
||||||
void operator()() const override { func_(); }
|
|
||||||
// The function pointer/reference
|
|
||||||
T func_;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<HolderBase> holder_ = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ~~~~ End Popen Args ~~~~
|
// ~~~~ End Popen Args ~~~~
|
||||||
|
|
||||||
|
|
||||||
|
@ -990,7 +952,6 @@ struct ArgumentDeducer
|
||||||
void set_option(output&& out);
|
void set_option(output&& out);
|
||||||
void set_option(error&& err);
|
void set_option(error&& err);
|
||||||
void set_option(close_fds&& cfds);
|
void set_option(close_fds&& cfds);
|
||||||
void set_option(preexec_func&& prefunc);
|
|
||||||
void set_option(session_leader&& sleader);
|
void set_option(session_leader&& sleader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1323,13 +1284,11 @@ private:
|
||||||
|
|
||||||
bool defer_process_start_ = false;
|
bool defer_process_start_ = false;
|
||||||
bool close_fds_ = false;
|
bool close_fds_ = false;
|
||||||
bool has_preexec_fn_ = false;
|
|
||||||
bool session_leader_ = false;
|
bool session_leader_ = false;
|
||||||
|
|
||||||
std::string exe_name_;
|
std::string exe_name_;
|
||||||
std::string cwd_;
|
std::string cwd_;
|
||||||
env_map_t env_;
|
env_map_t env_;
|
||||||
preexec_func preexec_fn_;
|
|
||||||
|
|
||||||
// Command in string format
|
// Command in string format
|
||||||
std::string args_;
|
std::string args_;
|
||||||
|
@ -1669,11 +1628,6 @@ namespace detail {
|
||||||
popen_->close_fds_ = cfds.close_all;
|
popen_->close_fds_ = cfds.close_all;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ArgumentDeducer::set_option(preexec_func&& prefunc) {
|
|
||||||
popen_->preexec_fn_ = std::move(prefunc);
|
|
||||||
popen_->has_preexec_fn_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void Child::execute_child() {
|
inline void Child::execute_child() {
|
||||||
#ifndef __USING_WINDOWS__
|
#ifndef __USING_WINDOWS__
|
||||||
|
@ -1737,10 +1691,6 @@ namespace detail {
|
||||||
if (sys_ret == -1) throw OSError("chdir failed", errno);
|
if (sys_ret == -1) throw OSError("chdir failed", errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent_->has_preexec_fn_) {
|
|
||||||
parent_->preexec_fn_();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent_->session_leader_) {
|
if (parent_->session_leader_) {
|
||||||
sys_ret = setsid();
|
sys_ret = setsid();
|
||||||
if (sys_ret == -1) throw OSError("setsid failed", errno);
|
if (sys_ret == -1) throw OSError("setsid failed", errno);
|
||||||
|
|
Loading…
Add table
Reference in a new issue