#reader #process

proc-reader

A std::io::Read implementation for stdout/stderr of other proccess

11 releases

0.5.1 May 16, 2023
0.5.0 Nov 25, 2020
0.4.0 Apr 25, 2018
0.3.1 Apr 22, 2018
0.1.2 Apr 9, 2018

#218 in Command-line interface

Download history 15/week @ 2023-07-28 24/week @ 2023-08-04 28/week @ 2023-08-11 16/week @ 2023-08-18 41/week @ 2023-08-25 18/week @ 2023-09-01 45/week @ 2023-09-08 17/week @ 2023-09-15 11/week @ 2023-09-22 26/week @ 2023-09-29 15/week @ 2023-10-06 29/week @ 2023-10-13 23/week @ 2023-10-20 39/week @ 2023-10-27 28/week @ 2023-11-03 14/week @ 2023-11-10

107 downloads per month
Used in pipecolor

MIT license

29KB
745 lines

proc-reader

Build Status Crates.io Docs.rs codecov

A std::io::Read implementation for stdout/stderr of other process

Documentation

Usage

[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

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);
}

Dependencies

~1.8–3.5MB
~64K SLoC