2 releases
Uses old Rust 2015
0.1.1 | Oct 2, 2022 |
---|---|
0.1.0 | Jun 9, 2018 |
#937 in Unix APIs
5KB
58 lines
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.
Dependencies
~44KB