FreeNOS
Data Structures | Public Types | Public Member Functions | Static Public Attributes | Static Private Attributes
ProcessClient Class Reference

ProcessClient provides information about all processes on the local core. More...

#include <ProcessClient.h>

Data Structures

struct  Info
 Process information. More...
 

Public Types

enum  Result { Success, NotFound, IOError }
 Result codes. More...
 
typedef struct ProcessClient::Info Info
 Process information. More...
 

Public Member Functions

ProcessID getProcessID () const
 Get current process identifier. More...
 
ProcessID getParentID () const
 Get parent process identifier. More...
 
Result processInfo (const ProcessID pid, Info &info) const
 Get process information by its ID. More...
 
Result processInfo (const String program, Info &info) const
 Get process information by its program name. More...
 
ProcessID findProcess (const String program) const
 Find a process by its program name. More...
 

Static Public Attributes

static const Size MaximumProcesses = MAX_PROCS
 Maximum number of processes. More...
 

Static Private Attributes

static const ProcessID m_pid = ProcessCtl(SELF, GetPID, 0)
 Our own process identifier. More...
 
static const ProcessID m_parent = ProcessCtl(SELF, GetParent, 0)
 Our parent process identifier. More...
 

Detailed Description

ProcessClient provides information about all processes on the local core.

See also
ProcessManager

Definition at line 39 of file ProcessClient.h.

Member Typedef Documentation

◆ Info

Process information.

Member Enumeration Documentation

◆ Result

Result codes.

Enumerator
Success 
NotFound 
IOError 

Definition at line 49 of file ProcessClient.h.

Member Function Documentation

◆ findProcess()

ProcessID ProcessClient::findProcess ( const String  program) const

Find a process by its program name.

Returns the information for the first process that is running the given program.

Parameters
programPath to the program
Returns
ProcessID of the first process that matches or ANY if none found.

Definition at line 92 of file ProcessClient.cpp.

References ANY, ProcessInfo::id, ProcessClient::Info::kernelState, processInfo(), and Success.

◆ getParentID()

ProcessID ProcessClient::getParentID ( ) const

Get parent process identifier.

Returns
Parent Process ID

Definition at line 32 of file ProcessClient.cpp.

References m_parent.

Referenced by getppid().

◆ getProcessID()

ProcessID ProcessClient::getProcessID ( ) const

Get current process identifier.

Returns
Current Process ID

Definition at line 27 of file ProcessClient.cpp.

References m_pid.

Referenced by getpid(), and setupRandomizer().

◆ processInfo() [1/2]

ProcessClient::Result ProcessClient::processInfo ( const ProcessID  pid,
ProcessClient::Info info 
) const

Get process information by its ID.

Parameters
pidProcess identifier of the process.
infoProcess information output
Returns
Result code

Definition at line 37 of file ProcessClient.cpp.

References ProcessClient::Info::command, InfoPID, IOError, ProcessClient::Info::kernelState, m_pid, NotFound, API::NotFound, ProcessCtl(), MemoryMap::range(), API::Read, ProcessInfo::state, Success, API::Success, ProcessClient::Info::textState, MemoryMap::UserArgs, Memory::Range::virt, and VMCopy().

Referenced by ProcessList::exec(), findProcess(), and processInfo().

◆ processInfo() [2/2]

ProcessClient::Result ProcessClient::processInfo ( const String  program,
ProcessClient::Info info 
) const

Get process information by its program name.

Returns the information for the first process that is running the given program.

Parameters
programPath to the program
infoProcess information output
Returns
Result code

Definition at line 76 of file ProcessClient.cpp.

References ProcessClient::Info::command, String::equals(), MaximumProcesses, NotFound, processInfo(), and Success.

Field Documentation

◆ m_parent

const ProcessID ProcessClient::m_parent = ProcessCtl(SELF, GetParent, 0)
staticprivate

Our parent process identifier.

Definition at line 130 of file ProcessClient.h.

Referenced by getParentID().

◆ m_pid

const ProcessID ProcessClient::m_pid = ProcessCtl(SELF, GetPID, 0)
staticprivate

Our own process identifier.

Definition at line 127 of file ProcessClient.h.

Referenced by getProcessID(), and processInfo().

◆ MaximumProcesses

const Size ProcessClient::MaximumProcesses = MAX_PROCS
static

Maximum number of processes.

Definition at line 44 of file ProcessClient.h.

Referenced by ProcessList::exec(), and processInfo().


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