libc_tools

Crates.iolibc_tools
lib.rslibc_tools
version0.1.3
sourcesrc
created_at2021-07-18 10:13:49.62535
updated_at2021-07-29 01:50:08.645768
descriptiona fork to std process
homepage
repository
max_upload_size
id424348
size26,964
cbw (lovebaihezi)

documentation

README

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);
    }
}
Commit count: 0

cargo fmt