authorgravatar for jcollie@dmacc.eduJeffrey C. Ollie <jcollie@dmacc.edu> 2024-07-29 13:07:19-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-07 13:03:21-07:00
log979fd12be96d5f8eda3e02ba676aecea78e6c0db
treed60b8162448bfaab3e0ef57d7eb0f47b94e54e26
parent87e8fc1ade38e764041166dc14cc7cee9382357b

Add getppid to std.c and std.os.linux.

The std lib is missing getppid, this patch adds it.

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

lib/std/c.zig+1
...@@ -9351,6 +9351,7 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int;...@@ -9351,6 +9351,7 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int;
9351pub extern "c" fn if_nametoindex([*:0]const u8) c_int;9351pub extern "c" fn if_nametoindex([*:0]const u8) c_int;
93529352
9353pub extern "c" fn getpid() pid_t;9353pub extern "c" fn getpid() pid_t;
9354pub extern "c" fn getppid() pid_t;
93549355
9355/// These are implementation defined but share identical values in at least musl and glibc:9356/// These are implementation defined but share identical values in at least musl and glibc:
9356/// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n189357/// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n18
lib/std/os/linux.zig+4
...@@ -1614,6 +1614,10 @@ pub fn getpid() pid_t {...@@ -1614,6 +1614,10 @@ pub fn getpid() pid_t {
1614 return @bitCast(@as(u32, @truncate(syscall0(.getpid))));1614 return @bitCast(@as(u32, @truncate(syscall0(.getpid))));
1615}1615}
16161616
1617pub fn getppid() pid_t {
1618 return @bitCast(@as(u32, @truncate(syscall0(.getppid))));
1619}
1620
1617pub fn gettid() pid_t {1621pub fn gettid() pid_t {
1618 return @bitCast(@as(u32, @truncate(syscall0(.gettid))));1622 return @bitCast(@as(u32, @truncate(syscall0(.gettid))));
1619}1623}
lib/std/os/linux/test.zig+4
...@@ -32,6 +32,10 @@ test "getpid" {...@@ -32,6 +32,10 @@ test "getpid" {
32 try expect(linux.getpid() != 0);32 try expect(linux.getpid() != 0);
33}33}
3434
35test "getppid" {
36 try expect(linux.getppid() != 0);
37}
38
35test "timer" {39test "timer" {
36 const epoll_fd = linux.epoll_create();40 const epoll_fd = linux.epoll_create();
37 var err: linux.E = linux.E.init(epoll_fd);41 var err: linux.E = linux.E.init(epoll_fd);