TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / external / process-cpp-minimal / include / core / posix / wait.h
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18
19 #ifndef CORE_POSIX_WAIT_H_
20 #define CORE_POSIX_WAIT_H_
21
22 #include <core/posix/exit.h>
23 #include <core/posix/signal.h>
24 #include <core/posix/visibility.h>
25
26 #include <bitset>
27
28 #include <cstdint>
29
30 #include <sys/wait.h>
31
32 namespace core
33 {
34 namespace posix
35 {
36 namespace wait
37 {
38
39 /**
40  * @brief Flags enumerates different behavior when waiting for a child process to change state.
41  */
42 enum class Flags : std::uint8_t
43 {
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.
47 };
48
49 CORE_POSIX_DLL_PUBLIC Flags operator|(Flags l, Flags r);
50
51 /**
52  * @brief The Result struct encapsulates the result of waiting for a process state change.
53  */
54 struct CORE_POSIX_DLL_PUBLIC Result
55 {
56     /**
57      * @brief The status of the process/wait operation.
58      */
59     enum class Status
60     {
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;
68
69     /**
70      * @brief Union of result-specific details.
71      */
72     union
73     {
74         /**
75          * Contains the exit status of the process if status == Status::exited.
76          */
77         struct
78         {
79             exit::Status status; ///< Exit status of the process.
80         } if_exited;
81
82         /**
83          * Contains the signal that caused the process to terminate if status == Status::signaled.
84          */
85         struct
86         {
87             Signal signal; ///< Signal that caused the process to terminate.
88             bool core_dumped; ///< true if the process termination resulted in a core dump.
89         } if_signaled;
90
91         /**
92          * Contains the signal that caused the process to terminate if status == Status::stopped.
93          */
94         struct
95         {
96             Signal signal; ///< Signal that caused the process to terminate.
97         } if_stopped;
98     } detail;
99 };
100 }
101 }
102 }
103
104 #endif // CORE_POSIX_WAIT_H_