JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
jh::sync::ipc::process_launcher< Path, IsBinary > Class Template Referencefinal

Cross-platform process launcher. More...

#include <jh/synchronous/ipc/process_launcher.h>

Classes

struct  handle
 Process handle representing a single launched instance. More...

Public Member Functions

 process_launcher ()=delete
 Not constructible.
 process_launcher (const process_launcher &)=delete
 Not copyable.
process_launcheroperator= (const process_launcher &)=delete
 Not assignable.

Static Public Member Functions

static handle start ()
 Launch the target process.

Detailed Description

template<jh::meta::TStr Path, bool IsBinary = true>
requires (limits::valid_relative_path<Path>())
class jh::sync::ipc::process_launcher< Path, IsBinary >

Cross-platform process launcher.

Template Parameters
PathExecutable path (compile-time string literal). Must be a relative path following POSIX rules:
  • Allowed characters: [A-Za-z0-9_.-/].
  • Must not begin with '/' (absolute paths forbidden).
  • "./" segments are disallowed.
  • ".." handling:
    • Default (JH_INTERPROCESS_ALLOW_PARENT_PATH == 0): any ".." is rejected.
    • Relaxed (JH_INTERPROCESS_ALLOW_PARENT_PATH == 1): only leading "../" prefixes are allowed, and the path must contain additional content afterwards.
    • Once non-empty content has been appended, ".." is forbidden.
  • Length must be in range [1, 128].
IsBinaryDistinguishes binary executables from scripts (Windows only).
  • If true: ".exe" is appended automatically on Windows (e.g. "writer""writer.exe").
  • If false: the path is used as-is (e.g. "script.ps1", "runner.bat").
  • On POSIX systems, this parameter has no effect: the given string is used directly (binary or script).

Path policy

  • Strict validation at compile time:
    • Illegal characters are rejected.
    • "./" or mid-path ".." segments are forbidden.
    • Absolute paths ("/foo/bar") are forbidden.
  • Parent path relaxation (JH_INTERPROCESS_ALLOW_PARENT_PATH):
    • Disabled (default = 0): any ".." usage is invalid.
    • Enabled (= 1): leading "../" prefixes are allowed, but the path cannot consist only of them.
  • Cross-platform normalization:
    • POSIX: path used as-is, relative to cwd.
    • Windows: forward slashes ('/') are translated automatically, backslashes are unnecessary.

Each instantiation corresponds to a specific executable determined at compile time. The type is unique per string literal and parameter combination.

Member Function Documentation

◆ start()

template<jh::meta::TStr Path, bool IsBinary = true>
handle jh::sync::ipc::process_launcher< Path, IsBinary >::start ( )
inlinestatic

Launch the target process.

On success, returns a handle which must be explicitly wait()-ed.

Exceptions
std::runtime_errorif process creation fails.

The documentation for this class was generated from the following file: