From 425d3fafed49cdf21fe2a18b2e29bea523017ccc Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 20 Apr 2025 16:42:24 -0700 Subject: [PATCH] add pause --- mod.zig | 8 +++++++- test.zig | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mod.zig b/mod.zig index 72032dc3b220476fdaa38a25f0314187efbfb716..8f0edaf10462073fd032a33f61633ecc5a507eb8 100644 --- a/mod.zig +++ b/mod.zig @@ -206,7 +206,13 @@ pub const dup2 = @compileError("TODO: dup2"); // pause // int pause(void); // asmlinkage long sys_pause(void); -pub const pause = @compileError("TODO: pause"); +pub fn pause() errno.Error!c_int { + const r = syscall0(.pause); + return switch (_errno(r)) { + .ok => @intCast(r), + _ => |c| errno.errorFromInt(@intFromEnum(c)), + }; +} // nanosleep // int nanosleep(const struct timespec *duration, struct timespec *_Nullable rem); diff --git a/test.zig b/test.zig index f7924d1c40d6d6a3e94842de961c877d583ec038..0c56a714a1ce33f5d622e9250da5ee185cc70f54 100644 --- a/test.zig +++ b/test.zig @@ -8,4 +8,5 @@ test { _ = &linux.read; _ = &linux.write; _ = &linux.sched_yield; + _ = &linux.pause; } -- 2.54.0