Kea 1.5.0
process_spawn.h
Go to the documentation of this file.
1// Copyright (C) 2015 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
11#include <boost/noncopyable.hpp>
12#include <string>
13#include <sys/types.h>
14#include <vector>
15
16namespace isc {
17namespace util {
18
21public:
22 ProcessSpawnError(const char* file, size_t line, const char* what) :
23 isc::Exception(file, line, what) { };
24};
25
28class ProcessSpawnImpl;
29
32typedef std::vector<std::string> ProcessArgs;
33
59
60class ProcessSpawn : boost::noncopyable {
61public:
62
67 ProcessSpawn(const std::string& executable,
68 const ProcessArgs& args = ProcessArgs());
69
72
74 std::string getCommandLine() const;
75
87 pid_t spawn();
88
98 bool isRunning(const pid_t pid) const;
99
103 bool isAnyRunning() const;
104
117 int getExitStatus(const pid_t pid) const;
118
131 void clearState(const pid_t pid);
132
133private:
134
136 ProcessSpawnImpl* impl_;
137
138};
139
140}
141}
142
143#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.
Exception thrown when error occurs during spawning a process.
Definition: process_spawn.h:20
ProcessSpawnError(const char *file, size_t line, const char *what)
Definition: process_spawn.h:22
Implementation of the ProcessSpawn class.
Utility class for spawning new processes.
Definition: process_spawn.h:60
bool isRunning(const pid_t pid) const
Checks if the process is still running.
bool isAnyRunning() const
Checks if any of the spawned processes is still running.
int getExitStatus(const pid_t pid) const
Returns exit status of the process.
std::string getCommandLine() const
Returns full command line, including arguments, for the process.
pid_t spawn()
Spawn the new process.
void clearState(const pid_t pid)
Removes the status of the process with a specified PID.
std::vector< std::string > ProcessArgs
Type of the container holding arguments of the executable being run as a background process.
Definition: process_spawn.h:32
Defines the logger used by the top-level component of kea-dhcp-ddns.