Add std.os.dup()

This commit is contained in:
Samadi van Koten
2021-06-07 22:06:45 +01:00
committed by Veikka Tuominen
parent 2d4c439652
commit ee048d6569
2 changed files with 14 additions and 0 deletions

View File

@@ -94,6 +94,10 @@ pub fn getErrno(r: usize) u12 {
return if (signed_r > -4096 and signed_r < 0) @intCast(u12, -signed_r) else 0;
}
pub fn dup(old: i32) usize {
return syscall1(.dup, @bitCast(usize, @as(isize, old)));
}
pub fn dup2(old: i32, new: i32) usize {
if (@hasField(SYS, "dup2")) {
return syscall2(.dup2, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)));