Kea  1.9.9-git
process_spawn.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef PROCESS_SPAWN_H
8 #define PROCESS_SPAWN_H
9 
10 #include <asiolink/io_service.h>
11 #include <exceptions/exceptions.h>
12 #include <boost/noncopyable.hpp>
13 #include <string>
14 #include <sys/types.h>
15 #include <vector>
16 #include <boost/shared_ptr.hpp>
17 
18 namespace isc {
19 namespace asiolink {
20 
22 class ProcessSpawnError : public Exception {
23 public:
24  ProcessSpawnError(const char* file, size_t line, const char* what) :
25  isc::Exception(file, line, what) { };
26 };
27 
31 
33 typedef boost::shared_ptr<ProcessSpawnImpl> ProcessSpawnImplPtr;
34 
37 typedef std::vector<std::string> ProcessArgs;
38 
41 typedef std::vector<std::string> ProcessEnvVars;
42 
61 class ProcessSpawn : boost::noncopyable {
62 public:
63 
71  const std::string& executable,
72  const ProcessArgs& args = ProcessArgs(),
73  const ProcessEnvVars& vars = ProcessEnvVars());
74 
76  ~ProcessSpawn() = default;
77 
79  std::string getCommandLine() const;
80 
94  pid_t spawn(bool dismiss = false);
95 
105  bool isRunning(const pid_t pid) const;
106 
110  bool isAnyRunning() const;
111 
124  int getExitStatus(const pid_t pid) const;
125 
138  void clearState(const pid_t pid);
139 
140 private:
141 
143  ProcessSpawnImplPtr impl_;
144 };
145 
146 } // namespace asiolink
147 } // namespace isc
148 
149 #endif // PROCESS_SPAWN_H
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.