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 › std/ › Io/ › Threaded.zig › processReplace
processReplace
Threaded.processReplace
fn processReplace (userdata : ?*anyopaque , options : process .ReplaceOptions ) process .ReplaceError
File
Code
fn processReplace (userdata : ?*anyopaque , options : process .ReplaceOptions ) process .ReplaceError {
const t : *Threaded = @ptrCast (@alignCast (userdata ));
if (!process .can_replace ) return error .OperationUnsupported ;
t .scanEnviron ();
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 );
}