The std.ChildProcess.exec function doesn't follow the expected behaviour of replacing the executable with the new program being exec'ed. See the SO question "Differences between fork and exec" for details on how fork and exec should behave.
Currently, std.ChildProcess.exec creates a std.ChildProcess instance and then calls its spawn method - returning an ExecResult struct:
|
pub fn exec(args: struct { |
|
allocator: *mem.Allocator, |
|
argv: []const []const u8, |
|
cwd: ?[]const u8 = null, |
|
cwd_dir: ?fs.Dir = null, |
|
env_map: ?*const BufMap = null, |
|
max_output_bytes: usize = 50 * 1024, |
|
expand_arg0: Arg0Expand = .no_expand, |
|
}) !ExecResult { |
|
const child = try ChildProcess.init(args.argv, args.allocator); |
|
defer child.deinit(); |
|
|
|
child.stdin_behavior = .Ignore; |
|
child.stdout_behavior = .Pipe; |
|
child.stderr_behavior = .Pipe; |
|
child.cwd = args.cwd; |
|
child.cwd_dir = args.cwd_dir; |
|
child.env_map = args.env_map; |
|
child.expand_arg0 = args.expand_arg0; |
|
|
|
try child.spawn(); |
I expect that std.ChildProcess.exec should not fork or spawn, and it should have a !noreturn result (perhaps ExecError!noreturn with ExecError being much the same as a SpawnError).
The
std.ChildProcess.execfunction doesn't follow the expected behaviour of replacing the executable with the new program beingexec'ed. See the SO question "Differences between fork and exec" for details on howforkandexecshould behave.Currently,
std.ChildProcess.execcreates astd.ChildProcessinstance and then calls itsspawnmethod - returning anExecResultstruct:zig/lib/std/child_process.zig
Lines 186 to 206 in f23987d
I expect that
std.ChildProcess.execshould notforkorspawn, and it should have a!noreturnresult (perhapsExecError!noreturnwithExecErrorbeing much the same as aSpawnError).