authorgravatar for wf@dewith.ioWim de With <wf@dewith.io> 2025-10-20 15:02:50+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-21 06:10:41+02:00
log8d4b5662cd3d34f106b0e5b636db8c0d14ed541c
tree50afcb8d132e30e728e395331779d67f77bbe63f
parentdbf9c7b548a56653c9267dbb615d7119974ecca5

std.{c,posix}: add getgid and getegid


3 files changed, 16 insertions(+), 0 deletions(-)

lib/std/c.zig+2
......@@ -10713,7 +10713,9 @@ pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;
1071310713pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;
1071410714pub extern "c" fn setpgid(pid: pid_t, pgid: pid_t) c_int;
1071510715pub extern "c" fn getuid() uid_t;
10716pub extern "c" fn getgid() gid_t;
1071610717pub extern "c" fn geteuid() uid_t;
10718pub extern "c" fn getegid() gid_t;
1071710719pub extern "c" fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) c_int;
1071810720pub extern "c" fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) c_int;
1071910721
lib/std/posix.zig+8
......@@ -3557,6 +3557,14 @@ pub fn geteuid() uid_t {
35573557 return system.geteuid();
35583558}
35593559
3560pub fn getgid() gid_t {
3561 return system.getgid();
3562}
3563
3564pub fn getegid() gid_t {
3565 return system.getegid();
3566}
3567
35603568/// Test whether a file descriptor refers to a terminal.
35613569pub fn isatty(handle: fd_t) bool {
35623570 if (native_os == .windows) {
lib/std/posix/test.zig+6
......@@ -314,6 +314,12 @@ test "getuid" {
314314 _ = posix.geteuid();
315315}
316316
317test "getgid" {
318 if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
319 _ = posix.getgid();
320 _ = posix.getegid();
321}
322
317323test "sigaltstack" {
318324 if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
319325