Poco

class PIDFile

Library: Foundation
Package: Processes
Header: Poco/PIDFile.h

Description

A utility class, creating process ID file on construction and deleting it on destruction.

Member Summary

Member Functions: contains, create, destroy, exists, getFileName, getName, getPID, setName

Types Aliases

Ptr

using Ptr = std::unique_ptr < PIDFile >;

Constructors

PIDFile

PIDFile();

Creates the PIDFile.

PIDFile

PIDFile(
    const std::string & fileName,
    bool write = true
);

Creates the PIDFile. If fileName is not empty, creates the PID file. If write is true, the file is written.

Destructor

~PIDFile

~PIDFile();

Destroys the PIDFile. If fileName is not empty, deletes the PID file.

Member Functions

contains static

static bool contains(
    const std::string & fileName,
    int pid
);

Returns true if the fileName contains the given pid.

create

void create();

Creates the file and writes PID into it.

destroy

void destroy();

Deletes the PID file and invalidates the held PID.

exists

bool exists() const;

Returns true if PID file exists and its content is equal to the held PID.

getFileName static

static std::string & getFileName(
    std::string & pidFile
);

Returns the file name.

getName inline

const std::string & getName() const;

Returns the file name.

getPID inline

int getPID() const;

Returns the PID.

setName

void setName(
    const std::string & fileName
);

Sets the file name.

Variables

INVALID_PID static

static const int INVALID_PID = - 1;