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
32 // Wrapper around a POSIX exit status
35 friend pid_t waitpid(pid_t, exit_status *, int);
40 exit_status() noexcept : status(0) { }
41 explicit exit_status(int status_p) noexcept : status(status_p) { }
43 bool did_exit() noexcept
45 return WIFEXITED(status);
48 bool did_exit_clean() noexcept
53 bool was_signalled() noexcept
55 return WIFSIGNALED(status);
58 int get_exit_status() noexcept
60 return WEXITSTATUS(status);
63 int get_term_sig() noexcept
65 return WTERMSIG(status);
74 inline pid_t waitpid(pid_t p, exit_status *statusp, int flags)
76 return ::waitpid(p, &statusp->status, flags);
81 #endif // BPSYS_INCLUDED