Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cppcoffee/vfork-rs
vfork-rs is used in embedded low memory to run an external program.
https://github.com/cppcoffee/vfork-rs
embedded vfork
Last synced: about 1 month ago
JSON representation
vfork-rs is used in embedded low memory to run an external program.
- Host: GitHub
- URL: https://github.com/cppcoffee/vfork-rs
- Owner: cppcoffee
- Created: 2023-09-24T05:26:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-24T09:08:46.000Z (over 1 year ago)
- Last Synced: 2024-04-25T17:05:36.108Z (9 months ago)
- Topics: embedded, vfork
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vfork-rs
`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.
## Notice
Used in linux only.
## Usage
```rust
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);
}
```## Reference
[https://man7.org/linux/man-pages/man2/vfork.2.html](https://man7.org/linux/man-pages/man2/vfork.2.html)