libcamera  v0.0.0
Supporting cameras in Linux since 2019
process.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  *
5  * process.h - Process object
6  */
7 #ifndef __LIBCAMERA_INTERNAL_PROCESS_H__
8 #define __LIBCAMERA_INTERNAL_PROCESS_H__
9 
10 #include <string>
11 #include <vector>
12 
14 
15 namespace libcamera {
16 
17 class Process final
18 {
19 public:
20  enum ExitStatus {
24  };
25 
26  Process();
27  ~Process();
28 
29  int start(const std::string &path,
30  const std::vector<std::string> &args = std::vector<std::string>(),
31  const std::vector<int> &fds = std::vector<int>());
32 
33  ExitStatus exitStatus() const { return exitStatus_; }
34  int exitCode() const { return exitCode_; }
35 
36  void kill();
37 
39 
40 private:
41  void closeAllFdsExcept(const std::vector<int> &fds);
42  int isolate();
43  void died(int wstatus);
44 
45  pid_t pid_;
46  bool running_;
47  enum ExitStatus exitStatus_;
48  int exitCode_;
49 
50  friend class ProcessManager;
51 };
52 
53 } /* namespace libcamera */
54 
55 #endif /* __LIBCAMERA_INTERNAL_PROCESS_H__ */
Manager of processes.
Definition: process.cpp:45
Process object.
Definition: process.h:18
void kill()
Kill the process.
Definition: process.cpp:374
int exitCode() const
Retrieve the exit code of the process.
Definition: process.h:34
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
ExitStatus
Exit status of process.
Definition: process.h:20
@ NormalExit
Definition: process.h:22
@ NotExited
Definition: process.h:21
@ SignalExit
Definition: process.h:23
Signal< Process *, enum ExitStatus, int > finished
Definition: process.h:38
ExitStatus exitStatus() const
Retrieve the exit status of the process.
Definition: process.h:33
Generic signal and slot communication mechanism.
Definition: signal.h:39
File descriptor event notifier.