aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorJan Hendrik Farr <kernel@jfarr.cc>2024-06-16 03:29:34 +0200
committerAndrew Kelley <andrew@ziglang.org>2024-08-08 01:12:26 -0700
commitca012e5b69b9ff275c6e366c0348219d1c816f18 (patch)
tree8a82fa41a2709de3377beb853988b8abc8c3f7de /lib/std
parent6976a5da19bf45f315eba2a0047977c6e659b2b3 (diff)
downloadzig-ca012e5b69b9ff275c6e366c0348219d1c816f18.tar.gz
zig-ca012e5b69b9ff275c6e366c0348219d1c816f18.zip
std.posix: read on timerfd can return error.Canceled
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/posix.zig5
-rw-r--r--lib/std/zig/system.zig1
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/std/posix.zig b/lib/std/posix.zig
index 296b7f9d53..bc270395cc 100644
--- a/lib/std/posix.zig
+++ b/lib/std/posix.zig
@@ -791,6 +791,10 @@ pub const ReadError = error{
/// and reading from the file descriptor would block.
WouldBlock,
+ /// reading a timerfd with CANCEL_ON_SET will lead to this error
+ /// when the clock goes through a discontinuous change
+ Canceled,
+
/// In WASI, this error occurs when the file descriptor does
/// not hold the required rights to read from it.
AccessDenied,
@@ -851,6 +855,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
.INVAL => unreachable,
.FAULT => unreachable,
.AGAIN => return error.WouldBlock,
+ .CANCELED => return error.Canceled,
.BADF => return error.NotOpenForReading, // Can be a race condition.
.IO => return error.InputOutput,
.ISDIR => return error.IsDir,
diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig
index 2c2f81825a..fe3394b615 100644
--- a/lib/std/zig/system.zig
+++ b/lib/std/zig/system.zig
@@ -1141,6 +1141,7 @@ fn preadAtLeast(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usi
const len = file.pread(buf[i..], offset + i) catch |err| switch (err) {
error.OperationAborted => unreachable, // Windows-only
error.WouldBlock => unreachable, // Did not request blocking mode
+ error.Canceled => unreachable, // timerfd is unseekable
error.NotOpenForReading => unreachable,
error.SystemResources => return error.SystemResources,
error.IsDir => return error.UnableToReadElfFile,