networkservice
Public Member Functions | Private Attributes | List of all members
utils::command::osal::Linux Class Reference

This class is the "low level class" that implements IOsal.h. More...

#include "utils/command/executor/osal/Linux.h"

Inheritance diagram for utils::command::osal::Linux:
Inheritance graph
[legend]
Collaboration diagram for utils::command::osal::Linux:
Collaboration graph
[legend]

Public Member Functions

 Linux ()
 
 ~Linux () override
 
 Linux (const Linux &)=delete
 
Linuxoperator= (const Linux &)=delete
 
 Linux (Linux &&)=delete
 
Linuxoperator= (Linux &&)=delete
 
ProcessId createProcess () const override
 creates a new process by duplicating the calling process. It can basically be a wrapper to fork() call. More...
 
void waitChildProcess () const override
 Wait for any child process whose process group ID is equal to that of the calling process. More...
 
void executeProgram (const char *pathname, char *const argv[], char *const envp[]) const override
 Execute the program referred to by pathname. More...
 
void reseedPRNG () const override
 Initialize the Random Number Generator for a new sequence of pseudo-random integers to be returned by rand() More...
 
void sanitizeFiles () const override
 Close all opened file descriptors except those related to the standard streams (stdin, stdout, stderr). These are only reopened to /dev/null if not already opened. More...
 
void dropPrivileges () const override
 Permanently drop the privileges of the process. More...
 
- Public Member Functions inherited from utils::command::osal::IOsal
 IOsal ()=default
 
virtual ~IOsal ()=default
 
 IOsal (const IOsal &)=delete
 
IOsaloperator= (const IOsal &)=delete
 
 IOsal (IOsal &&)=delete
 
IOsaloperator= (IOsal &&)=delete
 

Private Attributes

std::unique_ptr< Internal > m_internal
 

Additional Inherited Members

- Public Types inherited from utils::command::osal::IOsal
enum  ProcessId : unsigned int { CHILD = (1u << 0u), PARENT = (1u << 1u) }
 An id to inform caller about the current process type after a new process has been created. More...
 

Detailed Description

This class is the "low level class" that implements IOsal.h.

Note
Copy contructor, copy-assignment operator, move constructor and move-assignment operator are defined to be compliant with the "Rule of five"
See also
https://en.cppreference.com/w/cpp/language/rule_of_three
Author
Boubacar DIENE bouba.nosp@m.car..nosp@m.diene.nosp@m.@gma.nosp@m.il.co.nosp@m.m
Date
May 2020

Constructor & Destructor Documentation

◆ Linux() [1/3]

utils::command::osal::Linux::Linux ( )

◆ ~Linux()

utils::command::osal::Linux::~Linux ( )
override

Class destructor

Note
The override specifier aims at making the compiler warn if the base class's destructor is not virtual.

◆ Linux() [2/3]

utils::command::osal::Linux::Linux ( const Linux )
delete

Class copy constructor

◆ Linux() [3/3]

utils::command::osal::Linux::Linux ( Linux &&  )
delete

Class move constructor

Member Function Documentation

◆ createProcess()

ProcessId utils::command::osal::Linux::createProcess ( ) const
overridevirtual

creates a new process by duplicating the calling process. It can basically be a wrapper to fork() call.

Returns
An id of type ProcessId

Implements utils::command::osal::IOsal.

◆ dropPrivileges()

void utils::command::osal::Linux::dropPrivileges ( ) const
overridevirtual

Permanently drop the privileges of the process.

Implements utils::command::osal::IOsal.

◆ executeProgram()

void utils::command::osal::Linux::executeProgram ( const char *  pathname,
char *const  argv[],
char *const  envp[] 
) const
overridevirtual

Execute the program referred to by pathname.

Parameters
pathnameEither a binary executable, or a script starting with a line of the form: "#! interpreter [optional-arg]"
argvAn array of argument strings passed to the new program. By convention, the first of these strings should contain the filename associated with the file being executed.
envpAn array of strings of the form key=value, which are passed as environment to the new program.

Implements utils::command::osal::IOsal.

◆ operator=() [1/2]

Linux& utils::command::osal::Linux::operator= ( const Linux )
delete

Class copy-assignment operator

◆ operator=() [2/2]

Linux& utils::command::osal::Linux::operator= ( Linux &&  )
delete

Class move-assignment operator

◆ reseedPRNG()

void utils::command::osal::Linux::reseedPRNG ( ) const
overridevirtual

Initialize the Random Number Generator for a new sequence of pseudo-random integers to be returned by rand()

Implements utils::command::osal::IOsal.

◆ sanitizeFiles()

void utils::command::osal::Linux::sanitizeFiles ( ) const
overridevirtual

Close all opened file descriptors except those related to the standard streams (stdin, stdout, stderr). These are only reopened to /dev/null if not already opened.

Implements utils::command::osal::IOsal.

◆ waitChildProcess()

void utils::command::osal::Linux::waitChildProcess ( ) const
overridevirtual

Wait for any child process whose process group ID is equal to that of the calling process.

Implements utils::command::osal::IOsal.

Member Data Documentation

◆ m_internal

std::unique_ptr<Internal> utils::command::osal::Linux::m_internal
private

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