Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

@alexrp alexrp Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this doesn't exist on Windows.

I think it's "fine" in that it's no worse than many of the other declarations immediately surrounding it. Just noting that at some point we need to go through and change these declarations to be in line with the principles laid out in #20679. I don't think this necessarily has to block merging this PR, since that conversion work will likely be done in a batched fashion anyway.


/// 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
Expand Down
4 changes: 4 additions & 0 deletions lib/std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,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))));
}
Expand Down
4 changes: 4 additions & 0 deletions lib/std/os/linux/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down