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;