[][src]Module palaver::fork

A Rust fork wrapper that uses process descriptors (pdfork) on FreeBSD and normal fork elsewhere.

Process descriptors are like file descriptors but for processes:

  • they are immune to PID race conditions (they track the exact process in the kernel);
  • they work in the Capsicum capability mode sandbox.
extern crate libc;
extern crate palaver;
use palaver::fork::*;

match fork().unwrap() {
    ForkResult::Parent(child_proc) => {
        // do stuff
        // you can access child_proc.child_pid on any platform
        // you can also access child_proc.child_pd on FreeBSD
        if !child_proc.signal(libc::SIGTERM) {
            panic!("sigterm");
        }
    },
    ForkResult::Child => {
        // do stuff
    }
}

Structs

ChildHandle

Child process handle

Enums

ForkResult

Fork result

Functions

fork

Fork