Kea 2.5.8
pid_file.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 PID_FILE_H
8#define PID_FILE_H
9
11#include <boost/shared_ptr.hpp>
12#include <fstream>
13#include <ostream>
14#include <string>
15
16namespace isc {
17namespace util {
18
20class PIDFileError : public Exception {
21public:
22 PIDFileError(const char* file, size_t line, const char* what) :
23 isc::Exception(file, line, what) { };
24};
25
28class PIDCantReadPID : public Exception {
29public:
30 PIDCantReadPID(const char* file, size_t line, const char* what) :
31 isc::Exception(file, line, what) { };
32};
33
40class PIDFile {
41public:
45 PIDFile(const std::string& filename);
46
48 ~PIDFile();
49
62 int check() const;
63
69 void write(int) const;
70
74 void write() const;
75
79 void deleteFile() const;
80
82 std::string getFilename() const {
83 return (filename_);
84 }
85
86private:
88 std::string filename_;
89};
90
92typedef boost::shared_ptr<PIDFile> PIDFilePtr;
93
94} // namespace isc::util
95} // namespace isc
96
97#endif // PID_FILE_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 an error occurs trying to read a PID from an opened file.
Definition: pid_file.h:28
PIDCantReadPID(const char *file, size_t line, const char *what)
Definition: pid_file.h:30
Exception thrown when an error occurs during PID file processing.
Definition: pid_file.h:20
PIDFileError(const char *file, size_t line, const char *what)
Definition: pid_file.h:22
Class to help with processing PID files.
Definition: pid_file.h:40
~PIDFile()
Destructor.
Definition: pid_file.cc:22
void write() const
Get PID of the current process and write it to the file.
Definition: pid_file.cc:58
void deleteFile() const
Delete the PID file.
Definition: pid_file.cc:84
std::string getFilename() const
Returns the path to the PID file.
Definition: pid_file.h:82
int check() const
Read the PID in from the file and check it.
Definition: pid_file.cc:26
boost::shared_ptr< PIDFile > PIDFilePtr
Defines a shared pointer to a PIDFile.
Definition: pid_file.h:92
Defines the logger used by the top-level component of kea-lfc.