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 › processReplace Private Function processReplace Doc Source Private Function std.Io.Threaded.processReplace
fn processReplace (userdata : ?*anyopaque , options : process .ReplaceOptions ) process .ReplaceError Params userdata : ?*anyopaque options : process .ReplaceOptions File Io/Threaded.zig: 15101
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127 fn processReplace (userdata : ?*anyopaque , options : process .ReplaceOptions ) process .ReplaceError {
const t : *Threaded = @ptrCast (@alignCast (userdata ));
if (!process .can_replace ) return error .OperationUnsupported ;
t .scanEnviron (); // for PATH
const PATH = t .environ .string .PATH orelse default_PATH ;
var arena_allocator = std .heap .ArenaAllocator .init (t .allocator );
defer arena_allocator .deinit ();
const arena = arena_allocator .allocator ();
const argv_buf = try arena .allocSentinel (?[*:0 ]const u8 , options .argv .len , null );
for (options .argv , 0 ..) |arg , i | argv_buf [i ] = (try arena .dupeSentinel (u8 , arg , 0 )).ptr ;
const env_block = env_block : {
const prog_fd : i32 = -1 ;
if (options .environ_map ) |environ_map | break :env_block try environ_map .createPosixBlock (arena , .{
.zig_progress_fd = prog_fd ,
});
break :env_block try t .environ .process_environ .createPosixBlock (arena , .{
.zig_progress_fd = prog_fd ,
});
};
return posixExecv (options .expand_arg0 , argv_buf .ptr [0 ].?, argv_buf .ptr , env_block , PATH );
}