| ... | ... | @@ -293,19 +293,16 @@ pub fn killPosix(self: *ChildProcess) !Term { |
| 293 | 293 | error.ProcessNotFound => return error.AlreadyTerminated, |
| 294 | 294 | else => return err, |
| 295 | 295 | }; |
| 296 | | try self.waitUnwrapped(); |
| 296 | self.waitUnwrapped(); |
| 297 | 297 | return self.term.?; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | | /// Blocks until child process terminates and then cleans up all resources. |
| 301 | | pub fn wait(self: *ChildProcess) !Term { |
| 302 | | const term = if (native_os == .windows) |
| 303 | | try self.waitWindows() |
| 304 | | else |
| 305 | | try self.waitPosix(); |
| 300 | pub const WaitError = SpawnError || std.os.windows.GetProcessMemoryInfoError; |
| 306 | 301 | |
| 302 | /// Blocks until child process terminates and then cleans up all resources. |
| 303 | pub fn wait(self: *ChildProcess) WaitError!Term { |
| 304 | const term = if (native_os == .windows) try self.waitWindows() else self.waitPosix(); |
| 307 | 305 | self.id = undefined; |
| 308 | | |
| 309 | 306 | return term; |
| 310 | 307 | } |
| 311 | 308 | |
| ... | ... | @@ -408,7 +405,7 @@ pub fn run(args: struct { |
| 408 | 405 | }; |
| 409 | 406 | } |
| 410 | 407 | |
| 411 | | fn waitWindows(self: *ChildProcess) !Term { |
| 408 | fn waitWindows(self: *ChildProcess) WaitError!Term { |
| 412 | 409 | if (self.term) |term| { |
| 413 | 410 | self.cleanupStreams(); |
| 414 | 411 | return term; |
| ... | ... | @@ -418,17 +415,17 @@ fn waitWindows(self: *ChildProcess) !Term { |
| 418 | 415 | return self.term.?; |
| 419 | 416 | } |
| 420 | 417 | |
| 421 | | fn waitPosix(self: *ChildProcess) !Term { |
| 418 | fn waitPosix(self: *ChildProcess) SpawnError!Term { |
| 422 | 419 | if (self.term) |term| { |
| 423 | 420 | self.cleanupStreams(); |
| 424 | 421 | return term; |
| 425 | 422 | } |
| 426 | 423 | |
| 427 | | try self.waitUnwrapped(); |
| 424 | self.waitUnwrapped(); |
| 428 | 425 | return self.term.?; |
| 429 | 426 | } |
| 430 | 427 | |
| 431 | | fn waitUnwrappedWindows(self: *ChildProcess) !void { |
| 428 | fn waitUnwrappedWindows(self: *ChildProcess) WaitError!void { |
| 432 | 429 | const result = windows.WaitForSingleObjectEx(self.id, windows.INFINITE, false); |
| 433 | 430 | |
| 434 | 431 | self.term = @as(SpawnError!Term, x: { |
| ... | ... | @@ -450,7 +447,7 @@ fn waitUnwrappedWindows(self: *ChildProcess) !void { |
| 450 | 447 | return result; |
| 451 | 448 | } |
| 452 | 449 | |
| 453 | | fn waitUnwrapped(self: *ChildProcess) !void { |
| 450 | fn waitUnwrapped(self: *ChildProcess) void { |
| 454 | 451 | const res: posix.WaitPidResult = res: { |
| 455 | 452 | if (self.request_resource_usage_statistics) { |
| 456 | 453 | switch (native_os) { |