-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
std (posix): lower getpid
and getppid
into std.posix
#24027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
if (native_os == .wasi) return error.SkipZigTest; | ||
if (native_os == .windows) return error.SkipZigTest; | ||
if (native_os == .plan9 and !builtin.link_libc) return error.SkipZigTest; // No `getppid()`. | ||
if ((builtin.cpu.arch == .riscv32 or builtin.cpu.arch.isLoongArch()) and builtin.os.tag == .linux and !builtin.link_libc) return error.SkipZigTest; // No `getppid()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No getppid
? That seems unlikely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
riscv does return an error mentioning the missing syscall without linking libc (or at least a mapping to it). I'm not all too familiar with riscv or the syscall interfaces in Zig yet, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at lib/std/os/linux/syscalls.zig
, RISC-V definitely has the syscall number. (And this file is generated from kernel sources.)
Simply puts
getpid()
andgetppid()
intostd.posix
by making use ofposix.system
if available. Removes a tiny bit of boilerplate when making cross-Darwin-Linux platform stuff by not referencingstd.c
orstd.os.linux
directly.Also adds a proper test for
getppid()
. Kind of depends onfork()
andwaitpid()
but I'm not sure what the policy of inter-dependent tests are.