From 8d4b5662cd3d34f106b0e5b636db8c0d14ed541c Mon Sep 17 00:00:00 2001 From: Wim de With Date: Mon, 20 Oct 2025 15:02:50 +0200 Subject: [PATCH] std.{c,posix}: add getgid and getegid --- lib/std/c.zig | 2 ++ lib/std/posix.zig | 8 ++++++++ lib/std/posix/test.zig | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/lib/std/c.zig b/lib/std/c.zig index 248dd2f92f..9d9c7c5708 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -10713,7 +10713,9 @@ pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int; pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int; pub extern "c" fn setpgid(pid: pid_t, pgid: pid_t) c_int; pub extern "c" fn getuid() uid_t; +pub extern "c" fn getgid() gid_t; pub extern "c" fn geteuid() uid_t; +pub extern "c" fn getegid() gid_t; pub extern "c" fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) c_int; pub extern "c" fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) c_int; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index e3baab0a46..dd38f8202d 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -3557,6 +3557,14 @@ pub fn geteuid() uid_t { return system.geteuid(); } +pub fn getgid() gid_t { + return system.getgid(); +} + +pub fn getegid() gid_t { + return system.getegid(); +} + /// Test whether a file descriptor refers to a terminal. pub fn isatty(handle: fd_t) bool { if (native_os == .windows) { diff --git a/lib/std/posix/test.zig b/lib/std/posix/test.zig index 7294334ec1..ed329c911e 100644 --- a/lib/std/posix/test.zig +++ b/lib/std/posix/test.zig @@ -314,6 +314,12 @@ test "getuid" { _ = posix.geteuid(); } +test "getgid" { + if (native_os == .windows or native_os == .wasi) return error.SkipZigTest; + _ = posix.getgid(); + _ = posix.getegid(); +} + test "sigaltstack" { if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;