Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Io/ › Threaded.zig › dup2
dup2
Threaded.dup2
pub fn dup2 (old_fd : posix .fd_t , new_fd : posix .fd_t ) DupError !void
File
Code
pub fn dup2 (old_fd : posix .fd_t , new_fd : posix .fd_t ) DupError !void {
const syscall : Syscall = try .start ();
while (true ) switch (posix .errno (posix .system .dup2 (old_fd , new_fd ))) {
.SUCCESS => return syscall .finish (),
.BUSY , .INTR => {
try syscall .checkCancel ();
continue ;
},
.INVAL => |err | return syscall .errnoBug (err ),
.BADF => |err | return syscall .errnoBug (err ),
.MFILE => return syscall .fail (error .ProcessFdQuotaExceeded ),
.NOMEM => return syscall .fail (error .SystemResources ),
else => |err | return syscall .unexpectedErrno (err ),
};
}