2 * This header implements a namespace, bp_sys, which wraps various system calls used by baseproc-service.cc.
4 * When running tests, another header is substituted in place of this one. The substitute provides mocks/stubs
5 * for the functions, to avoid calling the real functions and thus allow for unit-level testing.
24 // Wrapper around a POSIX exit status
27 friend pid_t waitpid(pid_t, exit_status *, int);
32 exit_status() noexcept : status(0) { }
33 explicit exit_status(int status_p) noexcept : status(status_p) { }
35 bool did_exit() noexcept
37 return WIFEXITED(status);
40 bool did_exit_clean() noexcept
45 bool was_signalled() noexcept
47 return WIFSIGNALED(status);
50 int get_exit_status() noexcept
52 return WEXITSTATUS(status);
55 int get_term_sig() noexcept
57 return WTERMSIG(status);
66 inline pid_t waitpid(pid_t p, exit_status *statusp, int flags)
68 return ::waitpid(p, &statusp->status, flags);
73 #endif // BPSYS_INCLUDED