mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01:00
Add getppid to std.c and std.os.linux.
The std lib is missing getppid, this patch adds it.
This commit is contained in:
parent
87e8fc1ade
commit
979fd12be9
3 changed files with 9 additions and 0 deletions
|
|
@ -9351,6 +9351,7 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int;
|
|||
pub extern "c" fn if_nametoindex([*:0]const u8) c_int;
|
||||
|
||||
pub extern "c" fn getpid() pid_t;
|
||||
pub extern "c" fn getppid() pid_t;
|
||||
|
||||
/// These are implementation defined but share identical values in at least musl and glibc:
|
||||
/// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n18
|
||||
|
|
|
|||
|
|
@ -1614,6 +1614,10 @@ pub fn getpid() pid_t {
|
|||
return @bitCast(@as(u32, @truncate(syscall0(.getpid))));
|
||||
}
|
||||
|
||||
pub fn getppid() pid_t {
|
||||
return @bitCast(@as(u32, @truncate(syscall0(.getppid))));
|
||||
}
|
||||
|
||||
pub fn gettid() pid_t {
|
||||
return @bitCast(@as(u32, @truncate(syscall0(.gettid))));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ test "getpid" {
|
|||
try expect(linux.getpid() != 0);
|
||||
}
|
||||
|
||||
test "getppid" {
|
||||
try expect(linux.getppid() != 0);
|
||||
}
|
||||
|
||||
test "timer" {
|
||||
const epoll_fd = linux.epoll_create();
|
||||
var err: linux.E = linux.E.init(epoll_fd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue