aboutsummaryrefslogtreecommitdiff
path: root/lib/std/process
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-11-25 12:39:57 -0800
committerAndrew Kelley <andrew@ziglang.org>2024-11-25 14:18:55 -0800
commitaa5341bf85e2aab566ae235c24f85ddaf09e8aee (patch)
treef253058036dfd894f1125fb66c1b41cbe06c3262 /lib/std/process
parentf4e042a4c3e8e299d273f00b757ec9fce840c3a6 (diff)
downloadzig-aa5341bf85e2aab566ae235c24f85ddaf09e8aee.tar.gz
zig-aa5341bf85e2aab566ae235c24f85ddaf09e8aee.zip
std.process.Child: explicit error set for wait
Diffstat (limited to 'lib/std/process')
-rw-r--r--lib/std/process/Child.zig23
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/std/process/Child.zig b/lib/std/process/Child.zig
index bd0a91ce77..bb2c4c09a8 100644
--- a/lib/std/process/Child.zig
+++ b/lib/std/process/Child.zig
@@ -293,19 +293,16 @@ pub fn killPosix(self: *ChildProcess) !Term {
error.ProcessNotFound => return error.AlreadyTerminated,
else => return err,
};
- try self.waitUnwrapped();
+ self.waitUnwrapped();
return self.term.?;
}
-/// Blocks until child process terminates and then cleans up all resources.
-pub fn wait(self: *ChildProcess) !Term {
- const term = if (native_os == .windows)
- try self.waitWindows()
- else
- try self.waitPosix();
+pub const WaitError = SpawnError || std.os.windows.GetProcessMemoryInfoError;
+/// Blocks until child process terminates and then cleans up all resources.
+pub fn wait(self: *ChildProcess) WaitError!Term {
+ const term = if (native_os == .windows) try self.waitWindows() else self.waitPosix();
self.id = undefined;
-
return term;
}
@@ -408,7 +405,7 @@ pub fn run(args: struct {
};
}
-fn waitWindows(self: *ChildProcess) !Term {
+fn waitWindows(self: *ChildProcess) WaitError!Term {
if (self.term) |term| {
self.cleanupStreams();
return term;
@@ -418,17 +415,17 @@ fn waitWindows(self: *ChildProcess) !Term {
return self.term.?;
}
-fn waitPosix(self: *ChildProcess) !Term {
+fn waitPosix(self: *ChildProcess) SpawnError!Term {
if (self.term) |term| {
self.cleanupStreams();
return term;
}
- try self.waitUnwrapped();
+ self.waitUnwrapped();
return self.term.?;
}
-fn waitUnwrappedWindows(self: *ChildProcess) !void {
+fn waitUnwrappedWindows(self: *ChildProcess) WaitError!void {
const result = windows.WaitForSingleObjectEx(self.id, windows.INFINITE, false);
self.term = @as(SpawnError!Term, x: {
@@ -450,7 +447,7 @@ fn waitUnwrappedWindows(self: *ChildProcess) !void {
return result;
}
-fn waitUnwrapped(self: *ChildProcess) !void {
+fn waitUnwrapped(self: *ChildProcess) void {
const res: posix.WaitPidResult = res: {
if (self.request_resource_usage_statistics) {
switch (native_os) {