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 standard library.
std › Io › Threaded › dup2 Public Function dup2 Doc Source Public Function std.Io.Threaded.dup2
pub fn dup2 (old_fd : posix .fd_t , new_fd : posix .fd_t ) DupError !void Params File Io/Threaded.zig: 18288
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302 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 ), // invalid parameters
.BADF => |err | return syscall .errnoBug (err ), // use after free
.MFILE => return syscall .fail (error .ProcessFdQuotaExceeded ),
.NOMEM => return syscall .fail (error .SystemResources ),
else => |err | return syscall .unexpectedErrno (err ),
};
}