Commit 8d4b5662cd

Wim de With <wf@dewith.io>
2025-10-20 15:02:50
std.{c,posix}: add getgid and getegid
1 parent dbf9c7b
Changed files (3)
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;
 
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;
 
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) {