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.

captureChildProcess

Populates s.result_failed_command unconditionally.

Step.captureChildProcess
pub fn captureChildProcess(
    s: *Step,
    maker: *Maker,
    allocator: Allocator,
    options: CaptureChildProcessOptions,
) !std.process.RunResult

File

Code

pub fn captureChildProcess(
    s: *Step,
    maker: *Maker,
    allocator: Allocator,
    options: CaptureChildProcessOptions,
) !std.process.RunResult {
    const gpa = maker.gpa;
    const graph = maker.graph;
    const io = graph.io;

    s.setFailedCommand(gpa, options.argv, .{});

    try handleChildProcUnsupported(s, maker);
    try graph.handleVerbose(null, null, options.argv);

    const result = std.process.run(allocator, io, .{
        .argv = options.argv,
        .environ_map = options.environ_map orelse &graph.environ_map,
        .progress_node = options.progress_node,
    }) catch |err| {
        switch (err) {
            error.OutOfMemory, error.Canceled => |e| return e,
            error.FileNotFound => |e| if (options.allow_failure) return e,
            else => {},
        }
        return s.fail(maker, "failed to run {s}: {t}", .{ options.argv[0], err });
    };

    if (result.stderr.len > 0) try s.result_error_msgs.append(graph.arena, result.stderr);

    return result;
}