Skip to main content

spawn_process

Function spawn_process 

Source
pub fn spawn_process(
    bin_name: &str,
    args: &[&str],
    show_console: bool,
) -> Result<Child>
Expand description

Spawns a REKTAL binary (e.g. "kernel" or "gui") as an independent, detached process.

Resolves the sibling binary located alongside the current launcher executable and launches it with the provided CLI arguments.

§Arguments

  • bin_name - The base name of the target binary to spawn (e.g. "kernel", "gui"). On Windows, .exe is automatically checked and appended if applicable.
  • args - A slice of command-line argument strings to pass to the spawned process.
  • show_console - When true, opens the process inside a visible, native OS terminal window with a pause prompt on termination. When false, launches the process silently in the background with suppressed standard streams.

§Returns

Returns a std::io::Result<std::process::Child> representing the spawned child process handle.

§Errors

Returns an std::io::Error if:

  • The current executable path cannot be determined.
  • The target binary cannot be found or executed.
  • The platform terminal emulator cannot be spawned.

§Platform Behavior

  • Windows: Utilizes CREATE_NEW_CONSOLE and CREATE_NEW_PROCESS_GROUP creation flags.
  • Linux: Prioritizes $TERMINAL, xdg-terminal-exec, x-terminal-emulator, and fallback terminal emulators (gnome-terminal, konsole, xterm). Sets process_group(0) to decouple.
  • macOS: Dispatches script execution to Terminal.app via osascript or runs headless with process_group(0).