MemoryAccessor 1
A command-line front-end for exploring virtual memory of a linux process by accessing /proc/PID/mem file.
Loading...
Searching...
No Matches
ProcessApi Class Reference

A class with functionality to work with system processes. More...

#include <processapi.h>

Public Member Functions

void SetBufferSize (const size_t &buffer_size)
 Set buffer size of an instance.
std::unordered_set< pid_t > GetAllPids () const noexcept
 Get all PIDs existing in the system.
std::unordered_set< std::string > GetAllProcessNames () const noexcept
 Get all names of processes existing in the system.
std::unordered_set< pid_t > FindPidsByName (const std::string &name) const noexcept
 Get all PIDs by name of the process.
uint8_t PidExists (const pid_t &pid) const noexcept
 Check if a process with the given PID exists.
uint8_t ProcessExists (const std::string &pname) const noexcept
 Check if a process with the given name exists.

Detailed Description

A class with functionality to work with system processes.

This class provides a set of functions that perform work with processes currently existing in system. It contains functions such as finding PIDs by name of the process, getting all PIDs/process names and so on.

Member Function Documentation

◆ FindPidsByName()

std::unordered_set< pid_t > ProcessApi::FindPidsByName ( const std::string & name) const
noexcept

Get all PIDs by name of the process.

Parameters
[in]nameName of the process in type of std::string.
Returns
std::unordered_set with PIDs in pid_t type.

Get all process IDs that can be found by running "pgrep -x "process_name"" shell command.

◆ GetAllPids()

std::unordered_set< pid_t > ProcessApi::GetAllPids ( ) const
noexcept

Get all PIDs existing in the system.

Returns
std::unordered_set with all PIDs in pid_t type.

Get all process IDs that can be found by running "pgrep .+" shell command.

◆ GetAllProcessNames()

std::unordered_set< std::string > ProcessApi::GetAllProcessNames ( ) const
noexcept

Get all names of processes existing in the system.

Returns
std::unordered_set with all names in std::string type.

Get all names of processes that can be found by running "pgrep -l .+" shell command.

◆ PidExists()

uint8_t ProcessApi::PidExists ( const pid_t & pid) const
noexcept

Check if a process with the given PID exists.

Parameters
[in]pidPID of the process in pid_t type.
Returns
0 if process exists, 1 if process does not exist, 2 if there was an error while checking.

Check if a process with the given process ID exists in the system by checking if /proc/PID directory exists.

◆ ProcessExists()

uint8_t ProcessApi::ProcessExists ( const std::string & pname) const
noexcept

Check if a process with the given name exists.

Parameters
[in]pnameName of the process in type of std::string.
Returns
0 if process exists, 1 if process does not exist, 2 if there was an error while checking.

Check if a process with the given process name exists in the system by running "pgrep -x "process_name"" shell command.

◆ SetBufferSize()

void ProcessApi::SetBufferSize ( const size_t & buffer_size)
inline

Set buffer size of an instance.

Parameters
[in]buffer_sizeDesired buffer size in bytes.

Set buffer size, a number of bytes that are allocated when needed.


The documentation for this class was generated from the following files: