4 releases
0.1.3 | Jul 29, 2021 |
---|---|
0.1.2 | Jul 28, 2021 |
0.1.1 | Jul 22, 2021 |
0.1.0 | Jul 18, 2021 |
#15 in #parent
23 downloads per month
27KB
738 lines
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);
}
}
Dependencies
~44KB