Skip to content

Commit

Permalink
std.posix: map errno 6 (ENXIO) to error.NoDevice in write() (#22113)
Browse files Browse the repository at this point in the history
Co-authored-by: Saurabh <[email protected]>
  • Loading branch information
allocgator and allocgator authored Dec 10, 2024
1 parent 414fc3b commit c172877
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/std/posix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1270,6 +1273,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),
}
}
Expand Down

0 comments on commit c172877

Please sign in to comment.