2 * Copyright © 2013 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
19 #ifndef CORE_POSIX_WAIT_H_
20 #define CORE_POSIX_WAIT_H_
22 #include <core/posix/exit.h>
23 #include <core/posix/signal.h>
24 #include <core/posix/visibility.h>
40 * @brief Flags enumerates different behavior when waiting for a child process to change state.
42 enum class Flags : std::uint8_t
44 continued = WCONTINUED, ///< Also wait for a child to continue after having been stopped.
45 untraced = WUNTRACED, ///< Also wait for state changes in untraced children.
46 no_hang = WNOHANG ///< Do not block if a child process hasn't changed state.
49 CORE_POSIX_DLL_PUBLIC Flags operator|(Flags l, Flags r);
52 * @brief The Result struct encapsulates the result of waiting for a process state change.
54 struct CORE_POSIX_DLL_PUBLIC Result
57 * @brief The status of the process/wait operation.
61 undefined, ///< Marks an undefined state.
62 no_state_change, ///< No state change occured.
63 exited, ///< The process exited normally.
64 signaled, ///< The process was signalled and terminated.
65 stopped, ///< The process was signalled and stopped.
66 continued ///< The process resumed operation.
67 } status = Status::undefined;
70 * @brief Union of result-specific details.
75 * Contains the exit status of the process if status == Status::exited.
79 exit::Status status; ///< Exit status of the process.
83 * Contains the signal that caused the process to terminate if status == Status::signaled.
87 Signal signal; ///< Signal that caused the process to terminate.
88 bool core_dumped; ///< true if the process termination resulted in a core dump.
92 * Contains the signal that caused the process to terminate if status == Status::stopped.
96 Signal signal; ///< Signal that caused the process to terminate.
104 #endif // CORE_POSIX_WAIT_H_