popen_rs 0.1.0

Simple Process Spawning Library
Documentation
  • Coverage
  • 60%
    3 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 7.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 287.11 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • f42h/popen_rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • f42h

popen_rs - Simple Process Spawning Library

Description

This small Rust library simplifies the process of running system commands by 
spawning a new child process and reading the content of either the stdout 
or stderr stream handle.

Usage

  • Import the popen_rs crate to your source file
use popen_rs::Popen;

Methods

spawn

Spawns a new child process and captures the handles of stdout and stderr. This function will return the content of either stdout or stderr.
pub fn spawn(&mut self) -> io::Result<String>

pid

Requests the OS specified process identifier of the current child process.
pub fn pid(&mut self) -> Option<u32>

Example

use popen_rs::Popen;

fn main() {
    let command = "ls -l";
    let mut process = Popen::new(command);

    match process.spawn() {
        Ok(output) => {
            let pid = process.pid().unwrap();

            println!("Output of `{}` [PID:{}]:", command, pid);
            println!("\n{}", output);
        },
        Err(err) => eprintln!("Error: {}", err),
    }
}

License

This project is published under the MIT License.