diff --git a/kernel/include/kernel/Process.h b/kernel/include/kernel/Process.h index aab2fd599d..8bacfd654d 100644 --- a/kernel/include/kernel/Process.h +++ b/kernel/include/kernel/Process.h @@ -79,6 +79,7 @@ namespace Kernel BAN::ErrorOr sys_setegid(gid_t); BAN::ErrorOr sys_setreuid(uid_t, uid_t); BAN::ErrorOr sys_setregid(gid_t, gid_t); + BAN::ErrorOr sys_setpgrp(); BAN::ErrorOr sys_getuid() const { return m_credentials.ruid(); } BAN::ErrorOr sys_getgid() const { return m_credentials.rgid(); } diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 43ee8c1637..43f73e358f 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -1137,6 +1137,13 @@ namespace Kernel return 0; } + BAN::ErrorOr Process::sys_setpgrp() + { + LockGuard _(m_lock); + m_pgrp = pid(); + return pgrp(); + } + BAN::ErrorOr Process::absolute_path_of(BAN::StringView path) const { ASSERT(m_lock.is_locked()); diff --git a/kernel/kernel/Syscall.cpp b/kernel/kernel/Syscall.cpp index 5cde2d3948..eac7cdb189 100644 --- a/kernel/kernel/Syscall.cpp +++ b/kernel/kernel/Syscall.cpp @@ -173,6 +173,12 @@ namespace Kernel case SYS_GET_PID: ret = Process::current().pid(); break; + case SYS_GET_PGRP: + ret = Process::current().pgrp(); + break; + case SYS_SET_PGRP: + ret = Process::current().sys_setpgrp(); + break; default: dwarnln("Unknown syscall {}", syscall); break; diff --git a/libc/include/sys/syscall.h b/libc/include/sys/syscall.h index 912ace0124..6e1548b53b 100644 --- a/libc/include/sys/syscall.h +++ b/libc/include/sys/syscall.h @@ -48,6 +48,8 @@ __BEGIN_DECLS #define SYS_SIGNAL_DONE 41 #define SYS_TCSETPGRP 42 #define SYS_GET_PID 43 +#define SYS_GET_PGRP 44 +#define SYS_SET_PGRP 45 __END_DECLS diff --git a/libc/unistd.cpp b/libc/unistd.cpp index d924d65a27..93be4e195a 100644 --- a/libc/unistd.cpp +++ b/libc/unistd.cpp @@ -208,6 +208,11 @@ gid_t getegid(void) return syscall(SYS_GET_EGID); } +pid_t getpgrp(void) +{ + return syscall(SYS_GET_PGRP); +} + int seteuid(uid_t uid) { return syscall(SYS_SET_EUID, uid); @@ -238,6 +243,11 @@ int setregid(gid_t rgid, gid_t egid) return syscall(SYS_SET_REGID, rgid, egid); } +pid_t setpgrp(void) +{ + return syscall(SYS_SET_PGRP); +} + int tcsetpgrp(int fildes, pid_t pgid_id) { return syscall(SYS_TCSETPGRP, fildes, pgid_id);