posix/write: catch MSGSIZE error (#23238)

This commit is contained in:
Rémy Mathieu 2025-03-15 12:04:42 +01:00 committed by GitHub
parent 11b49e9002
commit 42160327dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -1198,6 +1198,10 @@ pub const WriteError = error{
/// 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,
/// The socket type requires that message be sent atomically, and the size of the message
/// to be sent made this impossible. The message is not transmitted.
MessageTooBig,
} || UnexpectedError;
/// Write to a file descriptor.
@ -1279,6 +1283,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
.CONNRESET => return error.ConnectionResetByPeer,
.BUSY => return error.DeviceBusy,
.NXIO => return error.NoDevice,
.MSGSIZE => return error.MessageTooBig,
else => |err| return unexpectedErrno(err),
}
}

View File

@ -202,6 +202,7 @@ const FmtError = error{
DestinationAddressRequired,
DiskQuota,
FileTooBig,
MessageTooBig,
InputOutput,
NoSpaceLeft,
AccessDenied,