summaryrefslogtreecommitdiff
path: root/Kernel/TTY.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/TTY.cpp')
-rw-r--r--Kernel/TTY.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/Kernel/TTY.cpp b/Kernel/TTY.cpp
index 3fc553a8bd..6b2f2fb34c 100644
--- a/Kernel/TTY.cpp
+++ b/Kernel/TTY.cpp
@@ -1,6 +1,8 @@
#include "TTY.h"
#include "Process.h"
+#include <LibC/errno_numbers.h>
#include <LibC/signal_numbers.h>
+#include <LibC/sys/ioctl_numbers.h>
TTY::TTY(unsigned major, unsigned minor)
: CharacterDevice(major, minor)
@@ -66,3 +68,22 @@ void TTY::set_termios(const Unix::termios& t)
should_echo_input(),
should_generate_signals());
}
+
+int TTY::ioctl(Process& process, unsigned request, unsigned arg)
+{
+ if (process.tty() != this)
+ return -ENOTTY;
+ switch (request) {
+ case TIOCGPGRP:
+ return pgid();
+ case TIOCSPGRP: {
+ // FIXME: Validate pgid fully.
+ pid_t pgid = static_cast<pid_t>(arg);
+ if (pgid < 0)
+ return -EINVAL;
+ set_pgid(arg);
+ return 0;
+ }
+ }
+ return -EINVAL;
+}