From aa5341bf85e2aab566ae235c24f85ddaf09e8aee Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Nov 2024 12:39:57 -0800 Subject: [PATCH 1/4] std.process.Child: explicit error set for wait --- lib/std/process/Child.zig | 23 ++++++++++------------- 1 file 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.?; } +pub const WaitError = SpawnError || std.os.windows.GetProcessMemoryInfoError; + /// 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 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) { From 775b48dd10c1af3f8d21f5bae3e0d2495dfcec67 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Nov 2024 12:58:25 -0800 Subject: [PATCH 2/4] std.io.Poller: handle EPIPE as EOF closes #17483 --- lib/std/io.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/std/io.zig b/lib/std/io.zig index 0a9b2bf867..640f575654 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -646,7 +646,10 @@ pub fn Poller(comptime StreamEnum: type) type { // always check if there's some data waiting to be read first. if (poll_fd.revents & posix.POLL.IN != 0) { const buf = try q.writableWithSize(bump_amt); - const amt = try posix.read(poll_fd.fd, buf); + const amt = posix.read(poll_fd.fd, buf) catch |err| switch (err) { + error.BrokenPipe => 0, // Handle the same as EOF. + else => |e| return e, + }; q.update(amt); if (amt == 0) { // Remove the fd when the EOF condition is met. From 21f0fce28bcceb5ee227f456401f250d9c62b31b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Nov 2024 13:18:45 -0800 Subject: [PATCH 3/4] CI: update macOS runner to 13 Apple has already dropped support for macOS 12. GitHub Actions is dropping macOS 12 support now. The Zig project is also dropping macOS 12 support now. This commit also bumps default minimum macos version to 13. --- .github/workflows/ci.yaml | 2 +- lib/std/Target.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bd5803a70f..81ab76d372 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,7 +46,7 @@ jobs: - name: Build and Test run: sh ci/aarch64-linux-release.sh x86_64-macos-release: - runs-on: "macos-12" + runs-on: "macos-13" env: ARCH: "x86_64" steps: diff --git a/lib/std/Target.zig b/lib/std/Target.zig index b2808255b0..ce912ab2cf 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -531,7 +531,7 @@ pub const Os = struct { }, .macos => .{ .semver = .{ - .min = .{ .major = 11, .minor = 7, .patch = 1 }, + .min = .{ .major = 13, .minor = 0, .patch = 0 }, .max = .{ .major = 15, .minor = 2, .patch = 0 }, }, }, From f6392b9526a457afe59f50abe97de397331037e3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Nov 2024 15:05:42 -0800 Subject: [PATCH 4/4] cmake: don't add an unnecessary curses static lib dependency --- CMakeLists.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca20a702bc..200a1cd2b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,12 +89,7 @@ set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries set(ZIG_STATIC_LLVM ${ZIG_STATIC} CACHE BOOL "Prefer linking against static LLVM libraries") set(ZIG_STATIC_ZLIB ${ZIG_STATIC} CACHE BOOL "Prefer linking against static zlib") set(ZIG_STATIC_ZSTD ${ZIG_STATIC} CACHE BOOL "Prefer linking against static zstd") -if(APPLE AND ZIG_STATIC) - set(ZIG_STATIC_CURSES on) -else() - set(ZIG_STATIC_CURSES off) -endif() -set(ZIG_STATIC_CURSES ${ZIG_STATIC_CURSES} CACHE BOOL "Prefer linking against static curses") +set(ZIG_STATIC_CURSES OFF CACHE BOOL "Enable static linking against curses") if (ZIG_SHARED_LLVM AND ZIG_STATIC_LLVM) message(SEND_ERROR "-DZIG_SHARED_LLVM and -DZIG_STATIC_LLVM cannot both be enabled simultaneously")