https://github.com/dalance/proc-reader
A std::io::Read implementation for stdout/stderr of other process
https://github.com/dalance/proc-reader
ptrace rust rust-library stderr stdout
Last synced: about 18 hours ago
JSON representation
A std::io::Read implementation for stdout/stderr of other process
- Host: GitHub
- URL: https://github.com/dalance/proc-reader
- Owner: dalance
- License: mit
- Created: 2018-04-09T08:41:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-28T20:55:50.000Z (about 2 years ago)
- Last Synced: 2025-01-02T01:42:06.797Z (9 months ago)
- Topics: ptrace, rust, rust-library, stderr, stdout
- Language: Rust
- Size: 47.9 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# proc-reader
[](https://travis-ci.org/dalance/proc-reader)
[](https://crates.io/crates/proc-reader)
[](https://docs.rs/proc-reader)
[](https://codecov.io/gh/dalance/proc-reader)A std::io::Read implementation for stdout/stderr of other process
[Documentation](https://docs.rs/proc-reader)
## Usage
```Cargo.toml
[dependencies]
proc-reader = "0.5.1"
```## Supported Platform
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- i686-unknown-linux-gnu
- i686-unknown-linux-musl## Example
```rust
extern crate proc_reader;
use proc_reader::ProcReader;
use std::process::Command;
use std::io::Read;
use std::time::Duration;
use std::thread;fn main() {
// Create a process for reading stdout
let child = Command::new("sh").arg("-c").arg("sleep 1; echo aaa").spawn().unwrap();// Create ProcReader from pid
let mut reader = ProcReader::from_stdout(child.id());// Wait the end of process
thread::sleep(Duration::from_secs(2));// Read from ProcReader
let mut line = String::new();
let _ = reader.read_to_string(&mut line);
assert_eq!( "aaa\n", line);
}
```