FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
pipe.hpp File Reference

Pipe handling utilities for subprocess. More...

#include <cstring>
#include <istream>
#include <thread>
#include <functional>
#include <optional>
#include <vector>
#include <sys/wait.h>
#include <sys/prctl.h>
#include <csignal>
#include <string>
#include <unistd.h>
#include <sys/types.h>
#include <filesystem>
#include "../../macro.hpp"
#include "../../lib/log.hpp"
#include "../../lib/linux/fd.hpp"
Include dependency graph for pipe.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  ns_subprocess
 Child process management and execution.
 
namespace  ns_subprocess::ns_pipe
 Inter-process pipe management.
 

Functions

void ns_subprocess::ns_pipe::write_pipe (pid_t child_pid, int pipe_fd, std::istream &stream)
 Write from an input stream to a pipe file descriptor.
 
void ns_subprocess::ns_pipe::read_pipe (pid_t child_pid, int pipe_fd, std::ostream &stream, std::filesystem::path const &path_file_log)
 Read from a pipe file descriptor and write to an output stream.
 
template<typename Stream>
bool ns_subprocess::ns_pipe::is_standard_stream (Stream &stream)
 Check if a stream is a standard stream (std::cin, std::cout, or std::cerr)
 
template<typename Stream>
void ns_subprocess::ns_pipe::pipes_child (bool is_istream, int pipe[2], Stream &stream, int fileno)
 Setup pipe for child process (unified for stdin/stdout/stderr)
 
template<typename Stream>
std::optional< std::jthread > ns_subprocess::ns_pipe::pipes_parent (pid_t child_pid, bool is_istream, int pipe[2], Stream &stream, std::filesystem::path const &path_file_log)
 Setup pipe for parent process (unified for stdin/stdout/stderr)
 
std::vector< std::jthread > ns_subprocess::ns_pipe::setup (pid_t pid, int pipestdin[2], int pipestdout[2], int pipestderr[2], std::istream &stdin, std::ostream &stdout, std::ostream &stderr, std::filesystem::path const &path_file_log)
 Handle pipe setup for both parent and child processes.
 

Detailed Description

Pipe handling utilities for subprocess.

Author
Ruan Formigoni

Definition in file pipe.hpp.