| Crates.io | cutlery |
| lib.rs | cutlery |
| version | 0.1.0 |
| created_at | 2025-07-24 15:12:11.603799+00 |
| updated_at | 2025-07-24 15:12:11.603799+00 |
| description | Cross-platform fork |
| homepage | https://github.com/jprendes/cutlery |
| repository | https://github.com/jprendes/cutlery |
| max_upload_size | |
| id | 1766175 |
| size | 31,285 |
A cross-platform (Unix and Windows) Rust library for process forking.
use std::io::{pipe, Read as _, Write as _};
use cutlery::fork_fn;
// create a pipe to communicate with the
// child process
let (mut r, mut w) = pipe()?;
let child = fork_fn(move || {
// this closure is running inside of the
// forked process
// send a message from the child process
w.write_all(b"hello world").unwrap();
std::process::exit(42);
})?;
// execution continues in the parent process
// read the message in the parent process
let mut buf = [0u8; 11];
r.read_exact(&mut buf)?;
assert_eq!(&buf, b"hello world");
// retrieve the exit status of the child process
let status = child.wait()?;
assert_eq!(status, 42);