Fonctions & utilitaires
FUNCTIONSNamespace: CppUtils::System
Énumérations publiques
Section intitulée « Énumérations publiques »enum class Signal { Abort = SIGABRT, Alarm = SIGALRM, Bus = SIGBUS, Child = SIGCHLD, Continue = SIGCONT, FloatingPointException = SIGFPE, Hangup = SIGHUP, IllegalInstruction = SIGILL, Interrupt = SIGINT, Io = SIGIO, Kill = SIGKILL, Pipe = SIGPIPE, ProfilingTimer = SIGPROF, Quit = SIGQUIT, SegmentationFault = SIGSEGV, Stop = SIGSTOP, System = SIGSYS, Terminate = SIGTERM, Trap = SIGTRAP, TerminalStop = SIGTSTP, TerminalInput = SIGTTIN, TerminalOutput = SIGTTOU, Urgent = SIGURG, User1 = SIGUSR1, User2 = SIGUSR2, VirtualAlarm = SIGVTALRM, WindowChange = SIGWINCH, CpuTimeLimit = SIGXCPU, FileSizeLimit = SIGXFSZ};Strongly-typed enumeration representing process signals across POSIX and non-POSIX platforms.
Under POSIX systems (Linux, macOS), enumerators map directly to system macros provided by <csignal>.
Under non-POSIX systems (such as Windows), the C Runtime only defines ISO C signals (SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM). Standard POSIX values (IEEE Std 1003.1 / Linux x86-64 ABI) are provided as fallback constants to guarantee compile-time compatibility with cross-platform test runners, event watchers, and matchers without requiring platform-specific #ifdef guards at call sites.
Voir aussi : Linux manual: signal(7)
Voir aussi : POSIX.1-2017: signal.h
Voir aussi : Microsoft Learn: Signal Constants
ExecutionStatus
Section intitulée « ExecutionStatus »enum class ExecutionStatus { Success = 0, Failure = 1};Execution outcome status recorded inside an isolated process.
Types publics
Section intitulée « Types publics »CrashCallback
Section intitulée « CrashCallback »using CppUtils::System::CrashCallback = typedef std::function<void(const CrashInformation&)>;ProcessId
Section intitulée « ProcessId »using CppUtils::System::ProcessId = typedef pid_t;using CppUtils::System::Library = typedef void*;using CppUtils::System::Handle = typedef std::intptr_t;Constantes & variables
Section intitulée « Constantes & variables »Fonctions publiques
Section intitulée « Fonctions publiques »Returns the symbolic name of a typed Signal.
| Paramètre | Description |
|---|---|
signal | Strongly-typed signal enumerator. |
Retourne : String view of the signal name (e.g. “SIGSEGV”, “SIGKILL”), or “Unknown”.
Voir aussi : Linux manual: signal(7)
Voir aussi : POSIX.1-2017: signal.h
Returns a human-readable diagnostic explanation for a termination signal.
| Paramètre | Description |
|---|---|
signal | Strongly-typed signal enumerator. |
Retourne : Detailed explanation of the signal’s probable cause, or empty string view if unknown.
Voir aussi : Linux manual: signal(7)
Creates a new child process via fork().
Sends a signal to a process using kill().
Waits for state changes in a child process via waitpid().
Terminates the calling process immediately without calling atexit or global destructors.
auto runIsolated(std::invocable auto&& function, std::chrono::milliseconds timeout=std::chrono::milliseconds{0}, std::function<void()> onBeforeExecution={}) -> std::expected<IsolatedExecutionResult, IsolatedExecutionFailure>;Executes a callable in an isolated child process, supervising execution and handling completion, timeout, and crash signals.
| Paramètre | Description |
|---|---|
function | Routine to execute in the child process. |
timeout | Maximum allowable execution duration (0ms for unlimited). |
onBeforeExecution | Optional hook invoked inside the child process immediately after fork. |
Retourne : Successful execution result or failure details.