pdfork

Crates.iopdfork
lib.rspdfork
version0.1.1
sourcesrc
created_at2018-06-09 23:19:05.706552
updated_at2022-10-02 00:07:44.657533
descriptionfork wrapper that uses process descriptors (pdfork) on FreeBSD and normal fork elsewhere
homepagehttps://codeberg.org/valpackett/pdfork
repositoryhttps://codeberg.org/valpackett/pdfork
max_upload_size
id69406
size5,646
Val Packett (valpackett)

documentation

README

unlicense crates.io

pdfork

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 pdfork;
use pdfork::*;

match fork() {
    ForkResult::Fail => panic!("fork"),
    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
    }
}

Contributing

By participating in this project you agree to follow the Contributor Code of Conduct.

The list of contributors is available on GitHub.

License

This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.

Commit count: 0

cargo fmt