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
5 * mocks/stubs for the functions, to avoid calling the real functions and thus allow for unit-level testing.
11 #include "dasynq.h" // for pipe2
13 #include <sys/uio.h> // writev
31 // Wrapper around a POSIX exit status
34 friend pid_t waitpid(pid_t, exit_status *, int);
39 exit_status() noexcept : status(0) { }
40 explicit exit_status(int status_p) noexcept : status(status_p) { }
42 bool did_exit() noexcept
44 return WIFEXITED(status);
47 bool did_exit_clean() noexcept
52 bool was_signalled() noexcept
54 return WIFSIGNALED(status);
57 int get_exit_status() noexcept
59 return WEXITSTATUS(status);
62 int get_term_sig() noexcept
64 return WTERMSIG(status);
73 inline pid_t waitpid(pid_t p, exit_status *statusp, int flags)
75 return ::waitpid(p, &statusp->status, flags);
80 #endif // BPSYS_INCLUDED