process.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* process.h - Process object
*/
#ifndef __LIBCAMERA_INTERNAL_PROCESS_H__
#define __LIBCAMERA_INTERNAL_PROCESS_H__
#include <string>
#include <vector>
#include <libcamera/event_notifier.h>
namespace libcamera {
class Process final
{
public:
enum ExitStatus {
NotExited,
NormalExit,
SignalExit,
};
Process();
~Process();
int start(const std::string &path,
const std::vector<std::string> &args = std::vector<std::string>(),
const std::vector<int> &fds = std::vector<int>());
ExitStatus exitStatus() const { return exitStatus_; }
int exitCode() const { return exitCode_; }
void kill();
Signal<Process *, enum ExitStatus, int> finished;
private:
void closeAllFdsExcept(const std::vector<int> &fds);
int isolate();
void died(int wstatus);
pid_t pid_;
bool running_;
enum ExitStatus exitStatus_;
int exitCode_;
friend class ProcessManager;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_PROCESS_H__ */
libcamera::ProcessManager
Manager of processes.
Definition: process.cpp:45
libcamera::Process
Process object.
Definition: process.h:18
libcamera::Process::kill
void kill()
Kill the process.
Definition: process.cpp:374
libcamera::Process::exitCode
int exitCode() const
Retrieve the exit code of the process.
Definition: process.h:34
libcamera::Process::start
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.
Definition: process.cpp:244
libcamera::Process::ExitStatus
ExitStatus
Exit status of process.
Definition: process.h:20
libcamera::Process::NormalExit
@ NormalExit
Definition: process.h:22
libcamera::Process::NotExited
@ NotExited
Definition: process.h:21
libcamera::Process::SignalExit
@ SignalExit
Definition: process.h:23
libcamera::Process::finished
Signal< Process *, enum ExitStatus, int > finished
Definition: process.h:38
libcamera::Process::exitStatus
ExitStatus exitStatus() const
Retrieve the exit status of the process.
Definition: process.h:33
libcamera::Signal
Generic signal and slot communication mechanism.
Definition: signal.h:39
event_notifier.h
File descriptor event notifier.