diff options
-rw-r--r-- | Kernel/TTY/TTY.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibC/unistd.cpp | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp index a58b882b4e..c5a7802133 100644 --- a/Kernel/TTY/TTY.cpp +++ b/Kernel/TTY/TTY.cpp @@ -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) diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index 83c1d465e6..0426054cb9 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -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) |