|
FlatImage
A configurable Linux containerization system
|
Dispatches child process requests to the portal daemon. More...
#include <chrono>#include <csignal>#include <cstdlib>#include <expected>#include <fcntl.h>#include <filesystem>#include <sys/prctl.h>#include <sys/stat.h>#include <sys/types.h>#include <sys/wait.h>#include <unistd.h>#include "../macro.hpp"#include "../std/expected.hpp"#include "../std/filesystem.hpp"#include "../lib/env.hpp"#include "../lib/log.hpp"#include "../lib/linux.hpp"#include "../lib/linux/fifo.hpp"#include "../lib/linux/fd.hpp"#include "../db/portal/message.hpp"#include "../db/portal/dispatcher.hpp"#include "config.hpp"Go to the source code of this file.
Functions | |
| void | signal_handler (int sig) |
| Forwards received signal to requested child process. | |
| void | register_signals () |
| Registers signal handlers for dispatcher cleanup. | |
| Value< void > | fifo_create (ns_message::Message const &msg) |
| Creates FIFOs for child process I/O. | |
| Value< void > | send_message (ns_message::Message const &message, fs::path const &path_fifo_daemon) |
| Sends a message to the portal daemon. | |
| Value< int > | process_wait (ns_message::Message const &message) |
| Waits for the requested process to finish. | |
| Value< int > | process_request (fs::path const &path_fifo_daemon, fs::path const &path_dir_fifo, std::vector< std::string > const &cmd) |
| Sends a request to the daemon to create a new process. | |
| int | main (int argc, char **argv) |
| Entry point for the portal dispatcher. | |
Variables | |
| char ** | environ |
| std::optional< pid_t > | opt_child = std::nullopt |
Dispatches child process requests to the portal daemon.
Definition in file portal_dispatcher.cpp.
|
nodiscard |
Creates FIFOs for child process I/O.
| msg | Message containing FIFO paths for stdin, stdout, and stderr |
Definition at line 83 of file portal_dispatcher.cpp.
| int main | ( | int | argc, |
| char ** | argv ) |
Entry point for the portal dispatcher.
| argc | Argument count |
| argv | Argument vector |
Definition at line 202 of file portal_dispatcher.cpp.
|
nodiscard |
Sends a request to the daemon to create a new process.
| cmd | Command to request, with it's respective arguments |
| daemon_target | "host" sends a command to the 'host' daemon and "guest" sends a command to the 'guest' daemon |
| path_dir_instance | Path to the instance directory to use |
Definition at line 173 of file portal_dispatcher.cpp.
|
nodiscard |
Waits for the requested process to finish.
Forwards the child's stdin/stdout/stderr to itself
| message | The message containing the FIFO paths |
Definition at line 125 of file portal_dispatcher.cpp.
| void register_signals | ( | ) |
Registers signal handlers for dispatcher cleanup.
Registers handlers for various signals (SIGINT, SIGTERM, etc.) to ensure proper cleanup when the dispatcher receives termination signals.
Definition at line 59 of file portal_dispatcher.cpp.
|
nodiscard |
Sends a message to the portal daemon.
| path_fifo_daemon | Path to the fifo which the daemon receives commands from |
| message | The message to send |
Definition at line 100 of file portal_dispatcher.cpp.
| void signal_handler | ( | int | sig | ) |
Forwards received signal to requested child process.
| sig | The signal to forward |
Definition at line 45 of file portal_dispatcher.cpp.
| std::optional<pid_t> opt_child = std::nullopt |
Definition at line 38 of file portal_dispatcher.cpp.