From 39639ae907637cb8355fbd0a63b1491616474cb5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:51:05 -0300 Subject: host_io.writeFd writes a shell's staged rc, an Upgrade's dump and a tape's buffer, each of which looped over write by hand (the tape's gave up at an EINTR) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/upgrade.zig | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/upgrade.zig') diff --git a/src/upgrade.zig b/src/upgrade.zig index 2e5f683f..d8f8f3c3 100644 --- a/src/upgrade.zig +++ b/src/upgrade.zig @@ -339,17 +339,9 @@ fn writeDump(path: [:0]const u8, bytes: []const u8) bool { const fd = libc.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .TRUNC = true, .CLOEXEC = true }, @as(libc.mode_t, 0o600)); if (fd < 0) return false; defer _ = libc.close(fd); - var at: usize = 0; - while (at < bytes.len) { - const n = libc.write(fd, bytes[at..].ptr, bytes.len - at); - if (n < 0 and libc.errno(n) == .INTR) continue; - if (n <= 0) { - _ = libc.unlink(path); - return false; - } - at += @intCast(n); - } - return true; + if (@import("host_io.zig").writeFd(fd, bytes)) return true; + _ = libc.unlink(path); + return false; } /// An Upgrade's dump, the terminal's and the window's alike: written -- cgit v1.3