libc_tools 0.1.3

a fork to std process
Documentation
  • Coverage
  • 0%
    0 out of 54 items documented0 out of 0 items with examples
  • Size
  • Source code size: 26.81 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.51 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lovebaihezi

libc_tools

this crate wrapper some sys_call in libc

thanks to libc this crate has some wrapper for libc: fork eg:

match Fork::fork() {
    ForkPid::Parent((parent, children)) => {}
    ForkPid::Children((parent, children)) => {}
    ForkPid::None => panic!("fork failed!")
}

forkpt dup dup2(and dup2s for mutliply fd)

let x : () = Dup::dup2s(&[...olds], &[...news]).unwrap();

popen how to use

unsafe {
    let popen = Popen::arg("date").exec().unwrap();
    let mut buf = [0 as u8; 4096];
    let mut p;
    while {
        p = fgets(buf.as_mut_ptr() as *mut i8, 4096, popen.stdout);
        p != std::ptr::null_mut::<i8>() && *p != '\0' as i8
    } {
        assert!(strlen(p) != 0);
    }
    println!("");
    while {
        p = fgets(buf.as_mut_ptr() as *mut i8, 4096, popen.stderr);
        p != std::ptr::null_mut::<i8>() && *p != '\0' as i8
    } {
        assert!(strlen(p) != 0);
    }
}