24#ifndef MYSQL_HARNESS_EXIT_STATUS_H_
25#define MYSQL_HARNESS_EXIT_STATUS_H_
81 constexpr std::optional<int>
exited()
const {
103 constexpr std::optional<int>
stopped()
const {
129 if (WIFSIGNALED(native_exit_code)) {
131 }
else if (WIFEXITED(native_exit_code)) {
133 }
else if (WIFSTOPPED(native_exit_code)) {
134 return {
stopped_t{}, WSTOPSIG(native_exit_code)};
135 }
else if (WIFCONTINUED(native_exit_code)) {
139 return {
exited_t{}, native_exit_code};
143 if (native_exit_code > 0xff || native_exit_code < 0) {
146 return {
exited_t{}, native_exit_code};
153 if (
auto code = st.
exited()) {
154 os <<
"Exit(" << *code <<
")";
157 os <<
"Terminated(signal=" << *code <<
") " << strsignal(*code);
160 hexed << std::showbase << std::hex << *code;
162 os <<
"Terminated(exception=" << hexed.str() <<
") "
163 << std::system_category().message(*code);
165 }
else if (
auto code = st.
stopped()) {
167 os <<
"Stopped(signal=" << *code <<
") " << strsignal(*code);
169 os <<
"Stopped(signal=" << *code <<
")";
exit status of processes.
Definition: exit_status.h:48
StatusKind status_kind_
Definition: exit_status.h:123
constexpr std::optional< int > stopped() const
check if the status is a stopped process.
Definition: exit_status.h:103
constexpr ExitStatus(terminated_t, int signum)
Definition: exit_status.h:67
constexpr bool continued() const
check if the status is continued process.
Definition: exit_status.h:112
constexpr ExitStatus(native_t, int native_exit_code)
Definition: exit_status.h:64
static constexpr ExitStatus from_native(int native_exit_code)
Definition: exit_status.h:127
StatusKind
Definition: exit_status.h:121
constexpr ExitStatus(exited_t, int exit_code)
Definition: exit_status.h:61
int status_
Definition: exit_status.h:125
constexpr ExitStatus(continued_t)
Definition: exit_status.h:73
constexpr std::optional< int > terminated() const
check if the status is a terminated exit.
Definition: exit_status.h:92
constexpr ExitStatus(stopped_t, int signum)
Definition: exit_status.h:70
friend bool operator==(const ExitStatus &a, const ExitStatus &b)
Definition: exit_status.h:116
constexpr ExitStatus(int exit_code)
construct a exit-status of a exited process.
Definition: exit_status.h:59
constexpr std::optional< int > exited() const
check if the status is a clean exit.
Definition: exit_status.h:81
#define WEXITSTATUS(stat_val)
Definition: client_priv.h:42
std::ostream & operator<<(std::ostream &os, const ExitStatus &st)
Definition: exit_status.h:152
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2871
Definition: exit_status.h:52
Definition: exit_status.h:54
Definition: exit_status.h:53
Definition: exit_status.h:51
Definition: exit_status.h:50