From 93d98f4e4e34e8d05982777da6ce979a8319f752 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Sun, 1 Dec 2024 01:30:08 +0530 Subject: [PATCH 1/2] handle errno(6) in os.write --- lib/std/posix.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 39b29ea76f02..256d4951aa2e 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -1270,6 +1270,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { .PIPE => return error.BrokenPipe, .CONNRESET => return error.ConnectionResetByPeer, .BUSY => return error.DeviceBusy, + .NXIO => return error.NoDevice, else => |err| return unexpectedErrno(err), } } From a1c8f4cccd6fbcc49a9836e446e76e791525fa30 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 3 Dec 2024 02:35:22 +0530 Subject: [PATCH 2/2] added 'NoDevice' to 'WriteError' --- lib/std/posix.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 256d4951aa2e..49d3fd8d6037 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -1191,6 +1191,9 @@ pub const WriteError = error{ /// This error occurs in Linux if the process being written to /// no longer exists. ProcessNotFound, + /// This error occurs when a device gets disconnected before or mid-flush + /// while it's being written to - errno(6): No such device or address. + NoDevice, } || UnexpectedError; /// Write to a file descriptor.