Skip to main content

spawn_in_group

Function spawn_in_group 

Source
pub fn spawn_in_group(
    config: SpawnInGroupConfig,
) -> SysprimsResult<SpawnInGroupResult>
Expand description

Spawn a process in a new process group on Unix.

Use this when you would otherwise shell out to setsid/wrapper scripts to make jobs kill-tree safe.

This PID-returning compatibility API cannot retain the owned child and sealed receipt required for TreeKillReliability::Guaranteed. Unix therefore reports best_effort; Windows fails closed because it cannot retain an owned Job handle. Use spawn_contained instead.

ยงExamples

use sysprims_timeout::{spawn_in_group, SpawnInGroupConfig};

// Replaces: setsid sleep 5
let result = spawn_in_group(SpawnInGroupConfig {
    argv: vec!["sleep".into(), "5".into()],
    cwd: None,
    env: None,
})
.unwrap();
println!("spawned pid: {}", result.pid);