diff options
| author | Jan Philipp Hafer <anon_1plus1equals3@mailbox.org> | 2023-10-19 22:36:11 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-10-22 14:47:20 -0400 |
| commit | fd2239bde9e2051a32fb25c50c732a40d4afccd0 (patch) | |
| tree | 4adce729cd1ed961e617e6a02413f179a2236885 /lib/std/child_process.zig | |
| parent | d8c067966fe88e15f9de5c42b83f1c5fbed550e4 (diff) | |
| download | zig-fd2239bde9e2051a32fb25c50c732a40d4afccd0.tar.gz zig-fd2239bde9e2051a32fb25c50c732a40d4afccd0.zip | |
child_process + Build: rename exec to run + all related code
Justification: exec, execv etc are unix concepts and portable version
should be called differently.
Do no touch non-Zig code. Adjust error names as well, if associated.
Closes #5853.
Diffstat (limited to 'lib/std/child_process.zig')
| -rw-r--r-- | lib/std/child_process.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index b815d89f7a..81c5bc1e03 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -262,7 +262,7 @@ pub const ChildProcess = struct { return term; } - pub const ExecResult = struct { + pub const RunResult = struct { term: Term, stdout: []u8, stderr: []u8, @@ -317,14 +317,14 @@ pub const ChildProcess = struct { stderr.* = fifoToOwnedArrayList(poller.fifo(.stderr)); } - pub const ExecError = os.GetCwdError || os.ReadError || SpawnError || os.PollError || error{ + pub const RunError = os.GetCwdError || os.ReadError || SpawnError || os.PollError || error{ StdoutStreamTooLong, StderrStreamTooLong, }; /// Spawns a child process, waits for it, collecting stdout and stderr, and then returns. /// If it succeeds, the caller owns result.stdout and result.stderr memory. - pub fn exec(args: struct { + pub fn run(args: struct { allocator: mem.Allocator, argv: []const []const u8, cwd: ?[]const u8 = null, @@ -332,7 +332,7 @@ pub const ChildProcess = struct { env_map: ?*const EnvMap = null, max_output_bytes: usize = 50 * 1024, expand_arg0: Arg0Expand = .no_expand, - }) ExecError!ExecResult { + }) RunError!RunResult { var child = ChildProcess.init(args.argv, args.allocator); child.stdin_behavior = .Ignore; child.stdout_behavior = .Pipe; @@ -352,7 +352,7 @@ pub const ChildProcess = struct { try child.spawn(); try child.collectOutput(&stdout, &stderr, args.max_output_bytes); - return ExecResult{ + return RunResult{ .term = try child.wait(), .stdout = try stdout.toOwnedSlice(), .stderr = try stderr.toOwnedSlice(), @@ -821,7 +821,7 @@ pub const ChildProcess = struct { const cmd_line_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, cmd_line); defer self.allocator.free(cmd_line_w); - exec: { + run: { const PATH: [:0]const u16 = std.os.getenvW(unicode.utf8ToUtf16LeStringLiteral("PATH")) orelse &[_:0]u16{}; const PATHEXT: [:0]const u16 = std.os.getenvW(unicode.utf8ToUtf16LeStringLiteral("PATHEXT")) orelse &[_:0]u16{}; @@ -873,7 +873,7 @@ pub const ChildProcess = struct { dir_buf.shrinkRetainingCapacity(normalized_len); if (windowsCreateProcessPathExt(self.allocator, &dir_buf, &app_buf, PATHEXT, cmd_line_w.ptr, envp_ptr, cwd_w_ptr, &siStartInfo, &piProcInfo)) { - break :exec; + break :run; } else |err| switch (err) { error.FileNotFound, error.AccessDenied, error.InvalidExe => continue, error.UnrecoverableInvalidExe => return error.InvalidExe, |
