| ... | @@ -798,6 +798,10 @@ pub const ReadError = error{ | ... | @@ -798,6 +798,10 @@ pub const ReadError = error{ |
| 798 | /// In WASI, this error occurs when the file descriptor does | 798 | /// In WASI, this error occurs when the file descriptor does |
| 799 | /// not hold the required rights to read from it. | 799 | /// not hold the required rights to read from it. |
| 800 | AccessDenied, | 800 | AccessDenied, |
| | 801 | |
| | 802 | /// This error occurs in Linux if the process to be read from |
| | 803 | /// no longer exists. |
| | 804 | ProcessNotFound, |
| 801 | } || UnexpectedError; | 805 | } || UnexpectedError; |
| 802 | | 806 | |
| 803 | /// Returns the number of bytes that were read, which can be less than | 807 | /// Returns the number of bytes that were read, which can be less than |
| ... | @@ -854,6 +858,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { | ... | @@ -854,6 +858,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 854 | .INTR => continue, | 858 | .INTR => continue, |
| 855 | .INVAL => unreachable, | 859 | .INVAL => unreachable, |
| 856 | .FAULT => unreachable, | 860 | .FAULT => unreachable, |
| | 861 | .NOENT => return error.ProcessNotFound, |
| 857 | .AGAIN => return error.WouldBlock, | 862 | .AGAIN => return error.WouldBlock, |
| 858 | .CANCELED => return error.Canceled, | 863 | .CANCELED => return error.Canceled, |
| 859 | .BADF => return error.NotOpenForReading, // Can be a race condition. | 864 | .BADF => return error.NotOpenForReading, // Can be a race condition. |
| ... | @@ -917,6 +922,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { | ... | @@ -917,6 +922,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { |
| 917 | .INTR => continue, | 922 | .INTR => continue, |
| 918 | .INVAL => unreachable, | 923 | .INVAL => unreachable, |
| 919 | .FAULT => unreachable, | 924 | .FAULT => unreachable, |
| | 925 | .NOENT => return error.ProcessNotFound, |
| 920 | .AGAIN => return error.WouldBlock, | 926 | .AGAIN => return error.WouldBlock, |
| 921 | .BADF => return error.NotOpenForReading, // can be a race condition | 927 | .BADF => return error.NotOpenForReading, // can be a race condition |
| 922 | .IO => return error.InputOutput, | 928 | .IO => return error.InputOutput, |
| ... | @@ -996,6 +1002,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { | ... | @@ -996,6 +1002,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 996 | .INTR => continue, | 1002 | .INTR => continue, |
| 997 | .INVAL => unreachable, | 1003 | .INVAL => unreachable, |
| 998 | .FAULT => unreachable, | 1004 | .FAULT => unreachable, |
| | 1005 | .NOENT => return error.ProcessNotFound, |
| 999 | .AGAIN => return error.WouldBlock, | 1006 | .AGAIN => return error.WouldBlock, |
| 1000 | .BADF => return error.NotOpenForReading, // Can be a race condition. | 1007 | .BADF => return error.NotOpenForReading, // Can be a race condition. |
| 1001 | .IO => return error.InputOutput, | 1008 | .IO => return error.InputOutput, |
| ... | @@ -1133,6 +1140,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { | ... | @@ -1133,6 +1140,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 1133 | .INTR => continue, | 1140 | .INTR => continue, |
| 1134 | .INVAL => unreachable, | 1141 | .INVAL => unreachable, |
| 1135 | .FAULT => unreachable, | 1142 | .FAULT => unreachable, |
| | 1143 | .NOENT => return error.ProcessNotFound, |
| 1136 | .AGAIN => return error.WouldBlock, | 1144 | .AGAIN => return error.WouldBlock, |
| 1137 | .BADF => return error.NotOpenForReading, // can be a race condition | 1145 | .BADF => return error.NotOpenForReading, // can be a race condition |
| 1138 | .IO => return error.InputOutput, | 1146 | .IO => return error.InputOutput, |
| ... | @@ -1176,6 +1184,10 @@ pub const WriteError = error{ | ... | @@ -1176,6 +1184,10 @@ pub const WriteError = error{ |
| 1176 | | 1184 | |
| 1177 | /// Connection reset by peer. | 1185 | /// Connection reset by peer. |
| 1178 | ConnectionResetByPeer, | 1186 | ConnectionResetByPeer, |
| | 1187 | |
| | 1188 | /// This error occurs in Linux if the process being written to |
| | 1189 | /// no longer exists. |
| | 1190 | ProcessNotFound, |
| 1179 | } || UnexpectedError; | 1191 | } || UnexpectedError; |
| 1180 | | 1192 | |
| 1181 | /// Write to a file descriptor. | 1193 | /// Write to a file descriptor. |
| ... | @@ -1243,6 +1255,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { | ... | @@ -1243,6 +1255,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 1243 | .INTR => continue, | 1255 | .INTR => continue, |
| 1244 | .INVAL => return error.InvalidArgument, | 1256 | .INVAL => return error.InvalidArgument, |
| 1245 | .FAULT => unreachable, | 1257 | .FAULT => unreachable, |
| | 1258 | .NOENT => return error.ProcessNotFound, |
| 1246 | .AGAIN => return error.WouldBlock, | 1259 | .AGAIN => return error.WouldBlock, |
| 1247 | .BADF => return error.NotOpenForWriting, // can be a race condition. | 1260 | .BADF => return error.NotOpenForWriting, // can be a race condition. |
| 1248 | .DESTADDRREQ => unreachable, // `connect` was never called. | 1261 | .DESTADDRREQ => unreachable, // `connect` was never called. |
| ... | @@ -1315,6 +1328,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { | ... | @@ -1315,6 +1328,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { |
| 1315 | .INTR => continue, | 1328 | .INTR => continue, |
| 1316 | .INVAL => return error.InvalidArgument, | 1329 | .INVAL => return error.InvalidArgument, |
| 1317 | .FAULT => unreachable, | 1330 | .FAULT => unreachable, |
| | 1331 | .NOENT => return error.ProcessNotFound, |
| 1318 | .AGAIN => return error.WouldBlock, | 1332 | .AGAIN => return error.WouldBlock, |
| 1319 | .BADF => return error.NotOpenForWriting, // Can be a race condition. | 1333 | .BADF => return error.NotOpenForWriting, // Can be a race condition. |
| 1320 | .DESTADDRREQ => unreachable, // `connect` was never called. | 1334 | .DESTADDRREQ => unreachable, // `connect` was never called. |
| ... | @@ -1404,6 +1418,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { | ... | @@ -1404,6 +1418,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 1404 | .INTR => continue, | 1418 | .INTR => continue, |
| 1405 | .INVAL => return error.InvalidArgument, | 1419 | .INVAL => return error.InvalidArgument, |
| 1406 | .FAULT => unreachable, | 1420 | .FAULT => unreachable, |
| | 1421 | .NOENT => return error.ProcessNotFound, |
| 1407 | .AGAIN => return error.WouldBlock, | 1422 | .AGAIN => return error.WouldBlock, |
| 1408 | .BADF => return error.NotOpenForWriting, // Can be a race condition. | 1423 | .BADF => return error.NotOpenForWriting, // Can be a race condition. |
| 1409 | .DESTADDRREQ => unreachable, // `connect` was never called. | 1424 | .DESTADDRREQ => unreachable, // `connect` was never called. |
| ... | @@ -1488,6 +1503,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz | ... | @@ -1488,6 +1503,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz |
| 1488 | .INTR => continue, | 1503 | .INTR => continue, |
| 1489 | .INVAL => return error.InvalidArgument, | 1504 | .INVAL => return error.InvalidArgument, |
| 1490 | .FAULT => unreachable, | 1505 | .FAULT => unreachable, |
| | 1506 | .NOENT => return error.ProcessNotFound, |
| 1491 | .AGAIN => return error.WouldBlock, | 1507 | .AGAIN => return error.WouldBlock, |
| 1492 | .BADF => return error.NotOpenForWriting, // Can be a race condition. | 1508 | .BADF => return error.NotOpenForWriting, // Can be a race condition. |
| 1493 | .DESTADDRREQ => unreachable, // `connect` was never called. | 1509 | .DESTADDRREQ => unreachable, // `connect` was never called. |