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 › c/ › unistd.zig › dup3Linux
dup3Linux
unistd.dup3Linux
fn dup3Linux (old : c_int , new : c_int , flags : c_int ) callconv (.c ) c_int
File
Code
fn dup3Linux (old : c_int , new : c_int , flags : c_int ) callconv (.c ) c_int {
const busy : usize = @bitCast (-@as (isize , @backingInt (linux .E .BUSY )));
var res = busy ;
if (@hasField (linux .SYS , "dup3" )) {
while (res == busy ) res = linux .dup3 (old , new , @intCast (flags ));
} else if (@hasField (linux .SYS , "dup2" )) {
const cloexec : c_int = @bitCast (linux .O { .CLOEXEC = true });
const inval : usize = @bitCast (-@as (isize , @backingInt (linux .E .INVAL )));
if (old == new or (flags & ~cloexec != 0 )) return errno (inval );
while (res == busy ) res = linux .dup2 (old , new );
_ = if (res >= 0 and (flags & cloexec == cloexec )) linux .fcntl (new , linux .F .SETFD , linux .FD_CLOEXEC );
} else {
return errno (@bitCast (-@as (isize , @backingInt (linux .E .NOSYS ))));
}
return errno (res );
}