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

This commit is contained in:
Wim de With 2025-10-20 15:02:50 +02:00 committed by Alex Rønne Petersen
parent dbf9c7b548
commit 8d4b5662cd
3 changed files with 16 additions and 0 deletions

View file

@ -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 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 setpgid(pid: pid_t, pgid: pid_t) c_int;
pub extern "c" fn getuid() uid_t; 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 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 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; pub extern "c" fn getresgid(rgid: *gid_t, egid: *gid_t, sgid: *gid_t) c_int;

View file

@ -3557,6 +3557,14 @@ pub fn geteuid() uid_t {
return system.geteuid(); 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. /// Test whether a file descriptor refers to a terminal.
pub fn isatty(handle: fd_t) bool { pub fn isatty(handle: fd_t) bool {
if (native_os == .windows) { if (native_os == .windows) {

View file

@ -314,6 +314,12 @@ test "getuid" {
_ = posix.geteuid(); _ = posix.geteuid();
} }
test "getgid" {
if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
_ = posix.getgid();
_ = posix.getegid();
}
test "sigaltstack" { test "sigaltstack" {
if (native_os == .windows or native_os == .wasi) return error.SkipZigTest; if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;