Kernel/LibC: Implement tcgetpgrp

This commit is contained in:
Bananymous 2024-12-02 03:59:23 +02:00
parent 6346e288ad
commit 6ed1435aeb
4 changed files with 25 additions and 0 deletions

View File

@ -179,6 +179,7 @@ namespace Kernel
BAN::ErrorOr<long> sys_sigpending(sigset_t* set); BAN::ErrorOr<long> sys_sigpending(sigset_t* set);
BAN::ErrorOr<long> sys_sigprocmask(int how, const sigset_t* set, sigset_t* oset); BAN::ErrorOr<long> sys_sigprocmask(int how, const sigset_t* set, sigset_t* oset);
BAN::ErrorOr<long> sys_tcgetpgrp(int fd);
BAN::ErrorOr<long> sys_tcsetpgrp(int fd, pid_t pgid); BAN::ErrorOr<long> sys_tcsetpgrp(int fd, pid_t pgid);
BAN::ErrorOr<long> sys_termid(char*); BAN::ErrorOr<long> sys_termid(char*);

View File

@ -2012,6 +2012,24 @@ namespace Kernel
return 0; return 0;
} }
BAN::ErrorOr<long> Process::sys_tcgetpgrp(int fd)
{
LockGuard _(m_process_lock);
if (!m_controlling_terminal)
return BAN::Error::from_errno(ENOTTY);
auto inode = TRY(m_open_file_descriptors.inode_of(fd));
if (!inode->is_tty())
return BAN::Error::from_errno(ENOTTY);
auto* tty = static_cast<TTY*>(inode.ptr());
if (tty != m_controlling_terminal.ptr())
return BAN::Error::from_errno(ENOTTY);
return tty->foreground_pgrp();
}
BAN::ErrorOr<long> Process::sys_tcsetpgrp(int fd, pid_t pgrp) BAN::ErrorOr<long> Process::sys_tcsetpgrp(int fd, pid_t pgrp)
{ {
LockGuard _(m_process_lock); LockGuard _(m_process_lock);

View File

@ -39,6 +39,7 @@ __BEGIN_DECLS
O(SYS_DUP, dup) \ O(SYS_DUP, dup) \
O(SYS_DUP2, dup2) \ O(SYS_DUP2, dup2) \
O(SYS_KILL, kill) \ O(SYS_KILL, kill) \
O(SYS_TCGETPGRP, tcgetpgrp) \
O(SYS_TCSETPGRP, tcsetpgrp) \ O(SYS_TCSETPGRP, tcsetpgrp) \
O(SYS_GET_PID, getpid) \ O(SYS_GET_PID, getpid) \
O(SYS_GET_PGID, getpgid) \ O(SYS_GET_PGID, getpgid) \

View File

@ -483,6 +483,11 @@ pid_t getpgid(pid_t pid)
return syscall(SYS_GET_PGID, pid); return syscall(SYS_GET_PGID, pid);
} }
int tcgetpgrp(int fildes)
{
return syscall(SYS_TCGETPGRP, fildes);
}
int seteuid(uid_t uid) int seteuid(uid_t uid)
{ {
return syscall(SYS_SET_EUID, uid); return syscall(SYS_SET_EUID, uid);