|
FlatImage
A configurable Linux containerization system
|
Handle to a spawned child process. More...
#include <child.hpp>
Public Member Functions | |
| ~Child () | |
| Destructor automatically waits for the child process. | |
| Child (Child const &)=delete | |
| Child & | operator= (Child const &)=delete |
| Child (Child &&)=delete | |
| Child & | operator= (Child &&)=delete |
| Value< int > | wait () |
| Waits for the child process to finish and returns exit code. | |
| std::optional< pid_t > | get_pid () const |
| Gets the PID of the child process. | |
| void | kill (int signal) |
| Sends a signal to the child process. | |
Friends | |
| class | Subprocess |
Handle to a spawned child process.
This class represents a running child process and provides methods to wait for it and retrieve its exit code. Returned by Subprocess::spawn().
The Child class uses RAII to ensure proper cleanup - the destructor automatically waits for the child process if it hasn't been waited on explicitly. This prevents zombie processes.
|
inline |
Destructor automatically waits for the child process.
Ensures child processes are properly cleaned up even if wait() is not called. This prevents zombie processes and resource leaks.
Definition at line 101 of file child.hpp.
|
inlinenodiscard |
Gets the PID of the child process.
Returns the process ID if the child is still valid (hasn't been waited on), or std::nullopt if wait() has already been called.
|
inline |
Sends a signal to the child process.
Sends the specified signal to the child process if it's still valid. Does nothing if the process has already been waited on.
| signal | The signal number to send (e.g., SIGTERM, SIGKILL) |
Definition at line 228 of file child.hpp.
|
inlinenodiscard |
Waits for the child process to finish and returns exit code.
Blocks until the child process terminates, then returns its exit code. Also cleans up any pipe reader processes created by Stream::Pipe mode. After wait() returns, the PID is invalidated (get_pid() returns nullopt).
Definition at line 149 of file child.hpp.
|
friend |