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.
fnprocessSpawn(userdata: ?*anyopaque, options: process.SpawnOptions) process.SpawnError!process.Child {
constev: *Evented = @ptrCast(@alignCast(userdata));
constspawned = tryev.spawn(options);
varcancel_region: CancelRegion = .initBlocked();
defercancel_region.deinit();
deferev.closeAsync(spawned.err_fd);
// Wait for the child to report any errors in or before `execvpe`.varchild_err: ForkBailError = undefined;
ev.readAll(&cancel_region, spawned.err_fd, @ptrCast(&child_err)) catch |read_err| {
switch (read_err) {
error.Canceled => unreachable, // blockederror.EndOfStream => {
// Write end closed by CLOEXEC at the time of the `execvpe` call,
// indicating success.
},
else => {
// Problem reading the error from the error reporting pipe. We
// don't know if the child is alive or dead. Better to assume it is
// alive so the resource does not risk being leaked.
},
}
return .{
.id = spawned.pid,
.thread_handle = {},
.stdin = spawned.stdin,
.stdout = spawned.stdout,
.stderr = spawned.stderr,
.request_resource_usage_statistics = options.request_resource_usage_statistics,
};
};
returnchild_err;
}