From 899e9b997d5cc1fb114b934266a183776a287c38 Mon Sep 17 00:00:00 2001 From: Ben Dang Date: Mon, 8 Oct 2018 00:15:10 -0700 Subject: [PATCH 1/2] Replace throw with noexcept for C17 compatibility (#17) C++11 started to deprecate the use of throw function identifiers. In C++17, this header no longer compiles due to the deprecation. Signed-off-by: Ben Dang --- subprocess.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/subprocess.hpp b/subprocess.hpp index ebf1484..dbae2eb 100755 --- a/subprocess.hpp +++ b/subprocess.hpp @@ -217,7 +217,7 @@ namespace util * Second element is the write descriptor of pipe. */ static inline - std::pair pipe_cloexec() throw (OSError) + std::pair pipe_cloexec() noexcept(false) { int pipe_fds[2]; int res = pipe(pipe_fds); @@ -965,15 +965,15 @@ public: if (!defer_process_start_) execute_process(); } - void start_process() throw (CalledProcessError, OSError); + void start_process() noexcept(false); int pid() const noexcept { return child_pid_; } int retcode() const noexcept { return retcode_; } - int wait() throw(OSError); + int wait() noexcept(false); - int poll() throw(OSError); + int poll() noexcept(false); // Does not fail, Caller is expected to recheck the // status with a call to poll() @@ -1017,7 +1017,7 @@ private: void init_args(F&& farg, Args&&... args); void init_args(); void populate_c_argv(); - void execute_process() throw (CalledProcessError, OSError); + void execute_process() noexcept(false); private: detail::Streams stream_; @@ -1066,7 +1066,7 @@ inline void Popen::populate_c_argv() cargv_.push_back(nullptr); } -inline void Popen::start_process() throw (CalledProcessError, OSError) +inline void Popen::start_process() noexcept(false) { // The process was started/tried to be started // in the constructor itself. @@ -1080,7 +1080,7 @@ inline void Popen::start_process() throw (CalledProcessError, OSError) execute_process(); } -inline int Popen::wait() throw (OSError) +inline int Popen::wait() noexcept(false) { int ret, status; std::tie(ret, status) = util::wait_for_child_exit(pid()); @@ -1095,7 +1095,7 @@ inline int Popen::wait() throw (OSError) return 0; } -inline int Popen::poll() throw (OSError) +inline int Popen::poll() noexcept(false) { int status; if (!child_created_) return -1; // TODO: ?? @@ -1137,7 +1137,7 @@ inline void Popen::kill(int sig_num) } -inline void Popen::execute_process() throw (CalledProcessError, OSError) +inline void Popen::execute_process() noexcept(false) { int err_rd_pipe, err_wr_pipe; std::tie(err_rd_pipe, err_wr_pipe) = util::pipe_cloexec(); From 0894e7f6db3b5d0b56c7608f88baf4418288174a Mon Sep 17 00:00:00 2001 From: ilue Date: Sat, 22 Dec 2018 03:07:51 +0800 Subject: [PATCH 2/2] Fix for preexec_func (#19) --- subprocess.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subprocess.hpp b/subprocess.hpp index dbae2eb..295550e 100755 --- a/subprocess.hpp +++ b/subprocess.hpp @@ -608,7 +608,7 @@ public: preexec_func() {} template - preexec_func(Func f): holder_(new FuncHolder(f)) + preexec_func(Func f): holder_(new FuncHolder(std::move(f))) {} void operator()() { @@ -621,8 +621,8 @@ private: }; template struct FuncHolder: HolderBase { - FuncHolder(T func): func_(func) {} - void operator()() const override {} + FuncHolder(T func): func_(std::move(func)) {} + void operator()() const override { func_(); } // The function pointer/reference T func_; };