Apache Mesos
reap.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License
12 
13 #ifndef __PROCESS_REAP_HPP__
14 #define __PROCESS_REAP_HPP__
15 
16 #include <sys/types.h>
17 
18 #include <process/future.hpp>
19 #include <process/id.hpp>
20 #include <process/process.hpp>
21 
22 #include <stout/multihashmap.hpp>
23 #include <stout/option.hpp>
24 #include <stout/result.hpp>
25 
26 namespace process {
27 
28 // The upper bound for the poll interval in the reaper.
30 
31 namespace internal {
32 
33 class ReaperProcess : public Process<ReaperProcess>
34 {
35 public:
36  ReaperProcess();
37 
39 
40 protected:
41  void initialize() override;
42 
43  void wait();
44 
45  void notify(pid_t pid, Result<int> status);
46 
47 private:
48  const Duration interval();
49 
51 };
52 
53 
54 // Global reaper process. Defined in process.cpp.
56 
57 } // namespace internal {
58 
59 
60 // Returns the exit status of the specified process if and only if
61 // the process is a direct child and it has not already been reaped.
62 // Otherwise, returns None once the process has been reaped elsewhere
63 // (or does not exist, which is indistinguishable from being reaped
64 // elsewhere). This will never fail or discard the returned future.
66 
67 } // namespace process {
68 
69 #endif // __PROCESS_REAP_HPP__
Duration MAX_REAP_INTERVAL()
PID< ReaperProcess > reaper
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
void initialize() override
Invoked when a process gets spawned.
Definition: duration.hpp:32
Definition: check.hpp:30
DWORD pid_t
Definition: windows.hpp:181
Definition: multihashmap.hpp:34
A "process identifier" used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:289
Definition: attributes.hpp:24
Definition: executor.hpp:48
void notify(pid_t pid, Result< int > status)
Definition: process.hpp:505
Future< Option< int > > reap(pid_t pid)
Definition: reap.hpp:33
Definition: future.hpp:58