24#ifndef MYSQL_HARNESS_EXIT_STATUS_H_
25#define MYSQL_HARNESS_EXIT_STATUS_H_
80 constexpr std::optional<int>
exited()
const {
102 constexpr std::optional<int>
stopped()
const {
128 if (WIFSIGNALED(native_exit_code)) {
130 }
else if (WIFEXITED(native_exit_code)) {
132 }
else if (WIFSTOPPED(native_exit_code)) {
133 return {
stopped_t{}, WSTOPSIG(native_exit_code)};
134 }
else if (WIFCONTINUED(native_exit_code)) {
138 return {
exited_t{}, native_exit_code};
142 if (native_exit_code > 0xff || native_exit_code < 0) {
145 return {
exited_t{}, native_exit_code};
152 if (
auto code = st.
exited()) {
153 os <<
"Exit(" << *code <<
")";
156 os <<
"Terminated(signal=" << *code <<
") " << strsignal(*code);
159 hexed << std::showbase << std::hex << *code;
161 os <<
"Terminated(exception=" << hexed.str() <<
") "
162 << std::system_category().message(*code);
164 }
else if (
auto code = st.
stopped()) {
166 os <<
"Stopped(signal=" << *code <<
") " << strsignal(*code);
168 os <<
"Stopped(signal=" << *code <<
")";
exit status of processes.
Definition: exit_status.h:47
StatusKind status_kind_
Definition: exit_status.h:122
constexpr std::optional< int > stopped() const
check if the status is a stopped process.
Definition: exit_status.h:102
constexpr ExitStatus(terminated_t, int signum)
Definition: exit_status.h:66
constexpr bool continued() const
check if the status is continued process.
Definition: exit_status.h:111
constexpr ExitStatus(native_t, int native_exit_code)
Definition: exit_status.h:63
static constexpr ExitStatus from_native(int native_exit_code)
Definition: exit_status.h:126
StatusKind
Definition: exit_status.h:120
constexpr ExitStatus(exited_t, int exit_code)
Definition: exit_status.h:60
int status_
Definition: exit_status.h:124
constexpr ExitStatus(continued_t)
Definition: exit_status.h:72
constexpr std::optional< int > terminated() const
check if the status is a terminated exit.
Definition: exit_status.h:91
constexpr ExitStatus(stopped_t, int signum)
Definition: exit_status.h:69
friend bool operator==(const ExitStatus &a, const ExitStatus &b)
Definition: exit_status.h:115
constexpr ExitStatus(int exit_code)
construct a exit-status of a exited process.
Definition: exit_status.h:58
constexpr std::optional< int > exited() const
check if the status is a clean exit.
Definition: exit_status.h:80
#define WEXITSTATUS(stat_val)
Definition: client_priv.h:41
std::ostream & operator<<(std::ostream &os, const ExitStatus &st)
Definition: exit_status.h:151
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2872
Definition: exit_status.h:51
Definition: exit_status.h:53
Definition: exit_status.h:52
Definition: exit_status.h:50
Definition: exit_status.h:49