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/host_io.zig | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/host_io.zig') diff --git a/src/host_io.zig b/src/host_io.zig index 2f1d8a3d..51699986 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -1441,21 +1441,10 @@ pub const Shell = struct { const path = std.fmt.bufPrintSentinel(path_buf, "{s}", .{template}, 0) catch return 0; const fd = mkstemp(path.ptr); if (fd < 0) return 0; - var off: usize = 0; - while (off < contents.len) { - const n = libc.write(fd, contents[off..].ptr, contents.len - off); - if (n < 0) { - if (libc.errno(n) == .INTR) continue; - _ = libc.close(fd); - _ = libc.unlink(path.ptr); - return 0; - } - if (n == 0) { - _ = libc.close(fd); - _ = libc.unlink(path.ptr); - return 0; - } - off += @intCast(n); + if (!writeFd(fd, contents)) { + _ = libc.close(fd); + _ = libc.unlink(path.ptr); + return 0; } if (libc.close(fd) != 0) { _ = libc.unlink(path.ptr); -- cgit v1.3