Skip to content

Commit

Permalink
Replace throw with noexcept for C17 compatibility (#17)
Browse files Browse the repository at this point in the history
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 <me@bdang.it>
  • Loading branch information
bdangit authored and arun11299 committed Oct 8, 2018
1 parent a90174c commit 899e9b9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions subprocess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace util
* Second element is the write descriptor of pipe.
*/
static inline
std::pair<int, int> pipe_cloexec() throw (OSError)
std::pair<int, int> pipe_cloexec() noexcept(false)
{
int pipe_fds[2];
int res = pipe(pipe_fds);
Expand Down Expand Up @@ -965,15 +965,15 @@ class Popen
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()
Expand Down Expand Up @@ -1017,7 +1017,7 @@ class Popen
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_;
Expand Down Expand Up @@ -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.
Expand All @@ -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());
Expand All @@ -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: ??
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 899e9b9

Please sign in to comment.