FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
ns_portal::ns_child Namespace Reference

Child process spawning and I/O management for portal IPC. More...

Functions

Value< void > write_fifo (int const value, fs::path const &path_fifo)
 Writes a value to a fifo given a file path.
 
Value< void > spawn (std::vector< std::string > const &vec_argv, ns_db::ns_portal::ns_message::Message const &message)
 Forks a child process and waits for it to complete.
 
Value< void > spawn (ns_daemon::ns_log::Logs logs, ns_message::Message const &message)
 Forks and executes a new child process.
 

Detailed Description

Child process spawning and I/O management for portal IPC.

This namespace handles the creation and management of child processes for the portal system. It provides functions for spawning processes with their standard I/O streams redirected to FIFO pipes, enabling communication between host and containerized processes. The spawned processes can have custom environments and communicate their PID and exit codes through FIFOs.

Function Documentation

◆ spawn() [1/2]

Value< void > ns_portal::ns_child::spawn ( ns_daemon::ns_log::Logs logs,
ns_message::Message const & message )
inlinenodiscard

Forks and executes a new child process.

Sets up child logging, extracts the command from the message, and spawns the child process. This function exits the parent process after spawning.

Parameters
logsLogging configuration with paths for log files
messageThe message containing the command, environment, and FIFO paths
Returns
Value<void> Success or error (note: exits on success via _exit(0))

Definition at line 159 of file child.hpp.

Here is the call graph for this function:

◆ spawn() [2/2]

Value< void > ns_portal::ns_child::spawn ( std::vector< std::string > const & vec_argv,
ns_db::ns_portal::ns_message::Message const & message )
inlinenodiscard

Forks a child process and waits for it to complete.

Spawns a child process with the specified command and arguments, redirects its stdio to pipes, and waits for it to exit. Communicates the child's PID and exit code through FIFOs to the portal daemon.

Parameters
logsLogging configuration with paths for log files
vec_argvArguments to the child process (first element is the command)
messageMessage containing FIFO paths and environment for IPC
Returns
Value<void> Success or error
Todo
Forward grand child pid to a log file

Definition at line 79 of file child.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_fifo()

Value< void > ns_portal::ns_child::write_fifo ( int const value,
fs::path const & path_fifo )
inlinenodiscard

Writes a value to a fifo given a file path.

Opens the fifo file with a timeout of SECONDS_TIMEOUT and writes the data

Parameters
valueThe value to write as a single integer constant
path_fifoThe path to the fifo file to open and write the data to
Returns
Value<void> Success or error

Definition at line 53 of file child.hpp.

Here is the call graph for this function:
Here is the caller graph for this function: