process-cpp  3.0.0
A simple convenience library for handling processes in C++11.
wait.h
Go to the documentation of this file.
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 
42 enum class Flags : std::uint8_t
43 {
44  continued = WCONTINUED,
45  untraced = WUNTRACED,
46  no_hang = WNOHANG
47 };
48 
50 
55 {
59  enum class Status
60  {
61  undefined,
62  no_state_change,
63  exited,
64  signaled,
65  stopped,
66  continued
67  } status = Status::undefined;
68 
72  union
73  {
77  struct
78  {
80  } if_exited;
81 
85  struct
86  {
88  bool core_dumped;
89  } if_signaled;
90 
94  struct
95  {
96  Signal signal;
97  } if_stopped;
98  } detail;
99 };
100 }
101 }
102 }
103 
104 #endif // CORE_POSIX_WAIT_H_
Signal signal
Signal that caused the process to terminate.
Definition: wait.h:87
#define CORE_POSIX_DLL_PUBLIC
Definition: visibility.h:26
Status
The Status enum wrap&#39;s the posix exit status.
Definition: exit.h:33
Flags
Flags enumerates different behavior when waiting for a child process to change state.
Definition: wait.h:42
Do not block if a child process hasn&#39;t changed state.
The Result struct encapsulates the result of waiting for a process state change.
Definition: wait.h:54
exit::Status status
Exit status of the process.
Definition: wait.h:79
Signal
The Signal enum collects the most common POSIX signals.
Definition: signal.h:38
Also wait for a child to continue after having been stopped.
Status
The status of the process/wait operation.
Definition: wait.h:59
bool core_dumped
true if the process termination resulted in a core dump.
Definition: wait.h:88
Also wait for state changes in untraced children.
CORE_POSIX_DLL_PUBLIC Flags operator|(Flags l, Flags r)
Definition: wait.cpp:27