Skip to main content

spawn_daemon_background

Function spawn_daemon_background 

Source
pub fn spawn_daemon_background(port: u16, token: &str) -> Result<u32, OlError>
Expand description

Spawn the daemon as a detached background process.

Gets the path to the current executable and re-executes with daemon start --foreground.

Platform-specific detachment:

  • Unix: process_group(0) creates a new process group (survives parent exit)
  • Windows: CREATE_NO_WINDOW suppresses the console window

Writes PID to config::openlatch_dir().join("daemon.pid") per PLAT-02.

§Errors

Returns an error if the child process cannot be spawned or PID file cannot be written.