57 std::string m_description;
58 std::vector<std::jthread> m_pipe_threads;
60 friend class Subprocess;
68 Child(pid_t pid, std::string description, std::vector<std::jthread> threads)
70 , m_description(std::move(description))
71 , m_pipe_threads(std::move(threads))
82 static std::unique_ptr<Child> create(pid_t pid, std::string
const& description, std::vector<std::jthread> threads = {})
84 return std::unique_ptr<Child>(
new Child(pid, description, std::move(threads)));
105 std::ignore =
wait();
152 return_if(m_pid <= 0, Error(
"E::Invalid pid to wait for in {}", m_description));
156 pid_t result = waitpid(m_pid, &status, 0);
161 return Error(
"D::Skipping wait on daemon process {}", m_pid);
163 return Error(
"E::waitpid failed on {}: {}", m_description, strerror(errno));
167 m_pipe_threads.clear();
172 return WIFEXITED(status)?
Value<int>(WEXITSTATUS(status))
173 : WIFSIGNALED(status)? Error(
"E::The process {} was terminated by a signal", m_description)
174 : WIFSTOPPED(status)? Error(
"E::The process {} was stopped by a signal", m_description)
175 : Error(
"E::The process {} exited abnormally", m_description);
202 [[nodiscard]] std::optional<pid_t>
get_pid()
const
204 return (m_pid > 0) ? std::optional<pid_t>(m_pid) : std::nullopt;