libcamera: libcamera::Process Class Reference

libcamera v0.7.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::Process Class Referencefinal

Process object. More...

Collaboration diagram for libcamera::Process:
[legend]

## Public Types
enum | ExitStatus { NotExited , NormalExit , SignalExit }
| Exit status of process. More...

## Public Member Functions
int | start (const std::string &path, Span< const std::string > args={}, Span< const int > fds={})
| Fork and exec a process, and close fds.
ExitStatus | exitStatus () const
| Retrieve the exit status of the process.
int | exitCode () const
| Retrieve the exit code of the process.
void | kill ()
| Kill the process.

## Public Attributes
Signal< enum ExitStatus, int > | finished

## 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

enum libcamera::Process::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()

int 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()

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,
|  | Span< const std::string > | args = {},
|  | Span< const int > | fds = {} )

Fork and exec a process, and close fds.

Parameters

  [in] | path | Path to executable
  [in] | args | Arguments to pass to executable (optional)
  [in] | fds | Vector 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

Signal<enum ExitStatus, int> 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:

- include/libcamera/internal/process.h
- src/libcamera/process.cpp