Kea 2.7.5
process_spawn.h
Go to the documentation of this file.
1// Copyright (C) 2015-2024 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>
12#include <boost/noncopyable.hpp>
13#include <string>
14#include <sys/types.h>
15#include <vector>
16#include <boost/shared_ptr.hpp>
17
18namespace isc {
19namespace asiolink {
20
23public:
24 ProcessSpawnError(const char* file, size_t line, const char* what) :
25 isc::Exception(file, line, what) { }
26};
27
30class ProcessSpawnImpl;
31
33typedef boost::shared_ptr<ProcessSpawnImpl> ProcessSpawnImplPtr;
34
37typedef std::vector<std::string> ProcessArgs;
38
41typedef std::vector<std::string> ProcessEnvVars;
42
61class ProcessSpawn : boost::noncopyable {
62public:
63
65 enum SpawnMode {
66 ASYNC, // thread continues without waiting for the child to finish.
67 SYNC // thread waits for the child to finish.
68 };
69
78 ProcessSpawn(const SpawnMode mode,
79 const std::string& executable,
80 const ProcessArgs& args = ProcessArgs(),
81 const ProcessEnvVars& vars = ProcessEnvVars(),
82 const bool inherit_env = false);
83
85 ~ProcessSpawn() = default;
86
88 std::string getCommandLine() const;
89
103 pid_t spawn(bool dismiss = false);
104
114 bool isRunning(const pid_t pid) const;
115
119 bool isAnyRunning() const;
120
133 int getExitStatus(const pid_t pid) const;
134
147 void clearState(const pid_t pid);
148
153 return (io_service_);
154 }
155
160 io_service_ = io_service;
161 }
162
163private:
164
166 static isc::asiolink::IOServicePtr io_service_;
167
170};
171
172} // namespace asiolink
173} // namespace isc
174
175#endif // PROCESS_SPAWN_H
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Defines the logger used by the top-level component of kea-lfc.