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