libcamera  v0.3.1+12-19bbca3c
Supporting cameras in Linux since 2019
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
libcamera::Process Class Referencefinal

Process object. More...

Collaboration diagram for libcamera::Process:
Collaboration graph
[legend]

Public Types

enum  ExitStatus { NotExited, NormalExit, SignalExit }
 Exit status of process. More...
 

Public Member Functions

int start (const std::string &path, const std::vector< std::string > &args=std::vector< std::string >(), const std::vector< int > &fds=std::vector< int >())
 Fork and exec a process, and close fds. More...
 
ExitStatus exitStatus () const
 Retrieve the exit status of the process. More...
 
int exitCode () const
 Retrieve the exit code of the process. More...
 
void kill ()
 Kill the process. More...
 

Public Attributes

Signal< enum ExitStatus, int > finished
 

Friends

class ProcessManager
 

Detailed Description

Process object.

The Process class models a process, and simplifies spawning new processes and monitoring the exiting of a process.

Member Enumeration Documentation

◆ ExitStatus

Exit status of process.

Enumerator
NotExited 

The process hasn't exited yet

NormalExit 

The process exited normally, either via exit() or returning from main

SignalExit 

The process was terminated by a signal (this includes crashing)

Member Function Documentation

◆ exitCode()

libcamera::Process::exitCode ( ) const
inline

Retrieve the exit code of the process.

This function is only valid if exitStatus() returned NormalExit.

Returns
Exit code

◆ exitStatus()

libcamera::Process::exitStatus ( ) const
inline

Retrieve the exit status of the process.

Return the exit status of the process, that is, whether the process has exited via exit() or returning from main, or if the process was terminated by a signal.

See also
ExitStatus
Returns
The process exit status

◆ kill()

void libcamera::Process::kill ( )

Kill the process.

Sends SIGKILL to the process.

◆ start()

int libcamera::Process::start ( const std::string &  path,
const std::vector< std::string > &  args = std::vector<std::string>(),
const std::vector< int > &  fds = std::vector<int>() 
)

Fork and exec a process, and close fds.

Parameters
[in]pathPath to executable
[in]argsArguments to pass to executable (optional)
[in]fdsVector of file descriptors to keep open (optional)

Fork a process, and exec the executable specified by path. Prior to exec'ing, but after forking, all file descriptors except for those specified in fds will be closed.

All indexes of args will be incremented by 1 before being fed to exec(), so args[0] should not need to be equal to path.

Returns
Zero on successful fork, exec, and closing the file descriptors, or a negative error code otherwise

Member Data Documentation

◆ finished

libcamera::Process::finished

Signal that is emitted when the process is confirmed to have terminated.


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