| Crates.io | vfork |
| lib.rs | vfork |
| version | 0.1.0 |
| created_at | 2023-09-24 09:09:22.552312+00 |
| updated_at | 2023-09-24 09:09:22.552312+00 |
| description | vfork-rs is used in embedded low memory to run an external program. |
| homepage | |
| repository | https://github.com/cppcoffee/vfork-rs |
| max_upload_size | |
| id | 981805 |
| size | 8,221 |
vfork-rs is used in embedded low memory to run an external program and read the stdout output.
Just like the name, the vfork-rs uses the linux vfork syscall. the vfork syscall is used to create new processes without copying the page tables of the parent process.
Used in linux only.
use vfork::Command;
fn main() {
let s = "hello, world!";
let mut cmd = Command::new("/bin/echo")
.arg(s)
.spawn()
.expect("failed to execute process");
let status_code = cmd.wait().expect("failed to wait process");
assert_eq!(0, status_code.code());
let output = cmd.output().expect("failed to get output");
assert_eq!(String::from_utf8_lossy(&output), s);
}