From ad1f175a39ab60504fecc4947b7291bc90a6fd1f Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 2 Dec 2024 05:55:25 +0200 Subject: [PATCH] Kernel/LibC: Implement getppid --- kernel/include/kernel/Process.h | 1 + userspace/libraries/LibC/include/sys/syscall.h | 1 + userspace/libraries/LibC/unistd.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/kernel/include/kernel/Process.h b/kernel/include/kernel/Process.h index 0044d586e5..6b22c16cf8 100644 --- a/kernel/include/kernel/Process.h +++ b/kernel/include/kernel/Process.h @@ -97,6 +97,7 @@ namespace Kernel BAN::ErrorOr sys_getegid() const { return m_credentials.egid(); } BAN::ErrorOr sys_getpgid(pid_t); + BAN::ErrorOr sys_getppid() const { return m_parent; } BAN::ErrorOr sys_getpid() const { return pid(); } BAN::ErrorOr open_inode(VirtualFileSystem::File&&, int flags); diff --git a/userspace/libraries/LibC/include/sys/syscall.h b/userspace/libraries/LibC/include/sys/syscall.h index f8073c6f3f..dbe1ee762e 100644 --- a/userspace/libraries/LibC/include/sys/syscall.h +++ b/userspace/libraries/LibC/include/sys/syscall.h @@ -41,6 +41,7 @@ __BEGIN_DECLS O(SYS_KILL, kill) \ O(SYS_TCGETPGRP, tcgetpgrp) \ O(SYS_TCSETPGRP, tcsetpgrp) \ + O(SYS_GET_PPID, getppid) \ O(SYS_GET_PID, getpid) \ O(SYS_GET_PGID, getpgid) \ O(SYS_SET_PGID, setpgid) \ diff --git a/userspace/libraries/LibC/unistd.cpp b/userspace/libraries/LibC/unistd.cpp index 7bc468023d..366152860e 100644 --- a/userspace/libraries/LibC/unistd.cpp +++ b/userspace/libraries/LibC/unistd.cpp @@ -489,6 +489,11 @@ error: return ret; } +pid_t getppid(void) +{ + return syscall(SYS_GET_PPID); +} + pid_t getpid(void) { return syscall(SYS_GET_PID);