Skip to main content

spawn_detached

Function spawn_detached 

Source
pub fn spawn_detached(args: &[&str], log_path: &Path) -> Result<u32>
Expand description

Spawn a detached daemon process by re-executing the current binary.

Creates a new session via setsid() so the child survives parent exit. Stdout and stderr are redirected to log_path.

Args:

  • args: Command-line arguments for the spawned process.
  • log_path: Path for stdout/stderr redirection.

Usage:

let pid = spawn_detached(
    &["agent", "start", "--foreground", "--socket", socket_str],
    &log_path,
)?;