4个版本
0.1.3 | 2021年7月29日 |
---|---|
0.1.2 | 2021年7月28日 |
0.1.1 | 2021年7月22日 |
0.1.0 | 2021年7月18日 |
#15 in #parent
每月23次下载
27KB
738 行
libc_tools
这个crate包装了一些libc中的系统调用
感谢libc,这个crate有一些对libc的包装:fork等
match Fork::fork() {
ForkPid::Parent((parent, children)) => {}
ForkPid::Children((parent, children)) => {}
ForkPid::None => panic!("fork failed!")
}
forkpt dup dup2(以及用于多个fd的dup2s)
let x : () = Dup::dup2s(&[...olds], &[...news]).unwrap();
popen 使用方法
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);
}
}
依赖项
~43KB