Skip to content

Commit 8d4b566

Browse files
wfdewithalexrp
authored andcommitted
std.{c,posix}: add getgid and getegid
1 parent dbf9c7b commit 8d4b566

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

lib/std/c.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10713,7 +10713,9 @@ pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;
1071310713
pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;
1071410714
pub extern "c" fn setpgid(pid: pid_t, pgid: pid_t) c_int;
1071510715
pub extern "c" fn getuid() uid_t;
10716+
pub extern "c" fn getgid() gid_t;
1071610717
pub extern "c" fn geteuid() uid_t;
10718+
pub extern "c" fn getegid() gid_t;
1071710719
pub extern "c" fn getresuid(ruid: *uid_t, euid: *uid_t, suid: *uid_t) c_int;
1071810720
pub extern "c" fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) c_int;
1071910721

lib/std/posix.zig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,6 +3557,14 @@ pub fn geteuid() uid_t {
35573557
return system.geteuid();
35583558
}
35593559

3560+
pub fn getgid() gid_t {
3561+
return system.getgid();
3562+
}
3563+
3564+
pub fn getegid() gid_t {
3565+
return system.getegid();
3566+
}
3567+
35603568
/// Test whether a file descriptor refers to a terminal.
35613569
pub fn isatty(handle: fd_t) bool {
35623570
if (native_os == .windows) {

lib/std/posix/test.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ test "getuid" {
314314
_ = posix.geteuid();
315315
}
316316

317+
test "getgid" {
318+
if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
319+
_ = posix.getgid();
320+
_ = posix.getegid();
321+
}
322+
317323
test "sigaltstack" {
318324
if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
319325

0 commit comments

Comments
 (0)