How to run a detached process

Hi,

I'm building a small updater application in Rust that replaces necessary files in the program being updated, and then re-launches it.

The file replacement parts work as expected, but I'm having issues with the re-spawning of the updated application. Currently, it only works by calling wait on the child process, but this runs the application inside the Rust program, so the updated application terminates when the Rust program terminates. I need to detach the updated program, similar to fork() in C. Currently, this is the only way that I can see the updated program launch. Exiting the Rust program without waiting, of course, launches the program, but immediately terminates it along with the Rust program.

let mut cmd = Command::new(exe_path); 

match cmd.spawn() {
    Ok(mut ch) => {
        let r = ch.wait().expect("Failed to wait for child process");
        exit(r.code().unwrap());
    },
    Err(e) => {
        println!("Spawn error: {}", e);
        exit(2);
    }
}

Any ideas how I accomplish this? I really don't want the entire program to run within this one.

Thanks!

::nix::unistd::fork() ?

I don't know how you would do it on Windows, though.