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 › Dispatch › pipe2 Private Function pipe2 Doc Source Private Function std.Io.Dispatch.pipe2
fn pipe2 (flags : c .O ) PipeError ![2 ]c .fd_t Params File Io/Dispatch.zig: 4425
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466 fn pipe2 (flags : c .O ) PipeError ![2 ]c .fd_t {
var fds : [2 ]c .fd_t = undefined ;
while (true ) switch (c .errno (c .pipe (&fds ))) {
.SUCCESS => break ,
.INTR => {},
.NFILE => return error .SystemFdQuotaExceeded ,
.MFILE => return error .ProcessFdQuotaExceeded ,
else => |err | return unexpectedErrno (err ),
};
errdefer {
closeFd (fds [0 ]);
closeFd (fds [1 ]);
}
// https://github.com/ziglang/zig/issues/18882
if (@as (u32 , @bitCast (flags )) == 0 ) return fds ;
// CLOEXEC is special, it's a file descriptor flag and must be set using
// F.SETFD.
if (flags .CLOEXEC ) for (fds ) |fd | while (true ) switch (c .errno (c .fcntl (fd , c .F .SETFD , @as (u32 , c .FD_CLOEXEC )))) {
.SUCCESS => break ,
.INTR => {},
else => |err | return unexpectedErrno (err ),
};
const new_flags : u32 = f : {
var new_flags = flags ;
new_flags .CLOEXEC = false ;
break :f @bitCast (new_flags );
};
// Set every other flag affecting the file status using F.SETFL.
if (new_flags != 0 ) for (fds ) |fd | while (true ) switch (c .errno (c .fcntl (fd , c .F .SETFL , new_flags ))) {
.SUCCESS => break ,
.INTR => {},
.INVAL => |err | return errnoBug (err ),
else => |err | return unexpectedErrno (err ),
};
return fds ;
}