Loading...
Searching...
No Matches
process.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Process object
*/
#pragma once
#include <string>
#include <libcamera/base/class.h>
#include <libcamera/base/signal.h>
#include <libcamera/base/span.h>
#include <libcamera/base/unique_fd.h>
namespace libcamera {
class EventNotifier;
class Process final
{
public:
enum ExitStatus {
NotExited,
NormalExit,
SignalExit,
};
Process();
~Process();
int start(const std::string &path,
Span<const std::string> args = {},
Span<const int> fds = {});
ExitStatus exitStatus() const { return exitStatus_; }
int exitCode() const { return exitCode_; }
void kill();
Signal<enum ExitStatus, int> finished;
private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(Process)
void onPidfdNotify();
pid_t pid_;
enum ExitStatus exitStatus_;
int exitCode_;
UniqueFD pidfd_;
std::unique_ptr<EventNotifier> pidfdNotify_;
};
} /* namespace libcamera */
class.h
Utilities to help constructing class interfaces.
LIBCAMERA_DISABLE_COPY_AND_MOVE
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
Definition class.h:29
libcamera::EventNotifier
Notify of activity on a file descriptor.
Definition event_notifier.h:20
libcamera::Process
Process object.
Definition process.h:22
libcamera::Process::kill
void kill()
Kill the process.
Definition process.cpp:281
libcamera::Process::start
int start(const std::string &path, Span< const std::string > args={}, Span< const int > fds={})
Fork and exec a process, and close fds.
Definition process.cpp:141
libcamera::Process::ExitStatus
ExitStatus
Exit status of process.
Definition process.h:24
libcamera::Process::SignalExit
@ SignalExit
Definition process.h:27
libcamera::Process::NotExited
@ NotExited
Definition process.h:25
libcamera::Process::NormalExit
@ NormalExit
Definition process.h:26
libcamera::Process::finished
Signal< enum ExitStatus, int > finished
Definition process.h:42
libcamera::Process::exitCode
int exitCode() const
Retrieve the exit code of the process.
Definition process.h:38
libcamera::Process::exitStatus
ExitStatus exitStatus() const
Retrieve the exit status of the process.
Definition process.h:37
libcamera::Signal
Generic signal and slot communication mechanism.
Definition signal.h:39
libcamera::UniqueFD
unique_ptr-like wrapper for a file descriptor
Definition unique_fd.h:17
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
signal.h
Signal & slot implementation.
unique_fd.h
File descriptor wrapper that owns a file descriptor.