1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:44:58 +00:00

Kernel+LibC: Use argument for TIOCGPGRP ioctl value

In preparation for modifying the Kernel IOCTL API to return KResult
instead of int, we need to fix this ioctl to an argument to receive
it's return value, instead of using the actual function return value.
This commit is contained in:
Brian Gianforcaro 2021-07-26 03:42:16 -07:00 committed by Ali Mohammad Pur
parent 9a04f53a0f
commit 46c9b1d81c
2 changed files with 12 additions and 3 deletions

View file

@ -469,8 +469,13 @@ int TTY::ioctl(FileDescription&, unsigned request, Userspace<void*> arg)
}
#endif
switch (request) {
case TIOCGPGRP:
return this->pgid().value();
case TIOCGPGRP: {
auto user_pgid = static_ptr_cast<pid_t*>(arg);
auto pgid = this->pgid().value();
if (!copy_to_user(user_pgid, &pgid))
return -EFAULT;
return 0;
}
case TIOCSPGRP: {
ProcessGroupID pgid = static_cast<pid_t>(arg.ptr());
if (pgid <= 0)

View file

@ -257,7 +257,11 @@ pid_t setsid()
pid_t tcgetpgrp(int fd)
{
return ioctl(fd, TIOCGPGRP);
pid_t pgrp;
int rc = ioctl(fd, TIOCGPGRP, &pgrp);
if (rc < 0)
return rc;
return pgrp;
}
int tcsetpgrp(int fd, pid_t pgid)