Kernel/LibC: Implement tcgetpgrp
This commit is contained in:
parent
6346e288ad
commit
6ed1435aeb
|
@ -179,6 +179,7 @@ namespace Kernel
|
|||
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_tcgetpgrp(int fd);
|
||||
BAN::ErrorOr<long> sys_tcsetpgrp(int fd, pid_t pgid);
|
||||
|
||||
BAN::ErrorOr<long> sys_termid(char*);
|
||||
|
|
|
@ -2012,6 +2012,24 @@ namespace Kernel
|
|||
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)
|
||||
{
|
||||
LockGuard _(m_process_lock);
|
||||
|
|
|
@ -39,6 +39,7 @@ __BEGIN_DECLS
|
|||
O(SYS_DUP, dup) \
|
||||
O(SYS_DUP2, dup2) \
|
||||
O(SYS_KILL, kill) \
|
||||
O(SYS_TCGETPGRP, tcgetpgrp) \
|
||||
O(SYS_TCSETPGRP, tcsetpgrp) \
|
||||
O(SYS_GET_PID, getpid) \
|
||||
O(SYS_GET_PGID, getpgid) \
|
||||
|
|
|
@ -483,6 +483,11 @@ pid_t getpgid(pid_t pid)
|
|||
return syscall(SYS_GET_PGID, pid);
|
||||
}
|
||||
|
||||
int tcgetpgrp(int fildes)
|
||||
{
|
||||
return syscall(SYS_TCGETPGRP, fildes);
|
||||
}
|
||||
|
||||
int seteuid(uid_t uid)
|
||||
{
|
||||
return syscall(SYS_SET_EUID, uid);
|
||||
|
|
Loading…
Reference in New Issue