-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
acceptedThis proposal is planned.This proposal is planned.breakingImplementing this issue could cause existing code to no longer compile or have different behavior.Implementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
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:
Lines 186 to 206 in f23987d
| 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).
daurnimator, androm3da, matu3ba and kiciuakme
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.breakingImplementing this issue could cause existing code to no longer compile or have different behavior.Implementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.