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.
26 // Wrapper around a POSIX exit status
29 friend pid_t waitpid(pid_t, exit_status *, int);
34 exit_status() noexcept : status(0) { }
35 explicit exit_status(int status_p) noexcept : status(status_p) { }
37 bool did_exit() noexcept
39 return WIFEXITED(status);
42 bool did_exit_clean() noexcept
47 bool was_signalled() noexcept
49 return WIFSIGNALED(status);
52 int get_exit_status() noexcept
54 return WEXITSTATUS(status);
57 int get_term_sig() noexcept
59 return WTERMSIG(status);
68 inline pid_t waitpid(pid_t p, exit_status *statusp, int flags)
70 return ::waitpid(p, &statusp->status, flags);
75 #endif // BPSYS_INCLUDED