diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-04-12 01:48:08 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2024-04-16 14:25:00 +0200 |
commit | cececad7b29e2ca3de1216db1c541dba6dc81bfa (patch) | |
tree | 899294470196cc9f710e11a255552086bf50862c /src | |
parent | 633e45b2e2728efcb0637afa94fcbd5756dfbe76 (diff) |
remove unneeded preexec function option from cpp-subprocess
We don't seem to ever need this, so remove it.
Diffstat (limited to 'src')
-rw-r--r-- | src/util/subprocess.hpp | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/util/subprocess.hpp b/src/util/subprocess.hpp index 96444ad1e7..1a98be3e1d 100644 --- a/src/util/subprocess.hpp +++ b/src/util/subprocess.hpp @@ -845,44 +845,6 @@ struct error 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 ~~~~ @@ -990,7 +952,6 @@ struct ArgumentDeducer void set_option(output&& out); void set_option(error&& err); void set_option(close_fds&& cfds); - void set_option(preexec_func&& prefunc); void set_option(session_leader&& sleader); private: @@ -1323,13 +1284,11 @@ private: bool defer_process_start_ = false; bool close_fds_ = false; - bool has_preexec_fn_ = false; bool session_leader_ = false; std::string exe_name_; std::string cwd_; env_map_t env_; - preexec_func preexec_fn_; // Command in string format std::string args_; @@ -1669,11 +1628,6 @@ namespace detail { 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() { #ifndef __USING_WINDOWS__ @@ -1737,10 +1691,6 @@ namespace detail { if (sys_ret == -1) throw OSError("chdir failed", errno); } - if (parent_->has_preexec_fn_) { - parent_->preexec_fn_(); - } - if (parent_->session_leader_) { sys_ret = setsid(); if (sys_ret == -1) throw OSError("setsid failed", errno); |