summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/TTY/MasterPTY.cpp12
-rw-r--r--Userland/Libraries/LibC/sys/ioctl_numbers.h2
2 files changed, 12 insertions, 2 deletions
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp
index cebb91529d..ce3f27f05e 100644
--- a/Kernel/TTY/MasterPTY.cpp
+++ b/Kernel/TTY/MasterPTY.cpp
@@ -125,9 +125,17 @@ ErrorOr<void> MasterPTY::ioctl(OpenFileDescription& description, unsigned reques
TRY(Process::current().require_promise(Pledge::tty));
if (!m_slave)
return EIO;
- if (request == TIOCSWINSZ || request == TIOCGPGRP)
+ switch (request) {
+ case TIOCGPTN: {
+ int master_pty_index = index();
+ return copy_to_user(static_ptr_cast<int*>(arg), &master_pty_index);
+ }
+ case TIOCSWINSZ:
+ case TIOCGPGRP:
return m_slave->ioctl(description, request, arg);
- return EINVAL;
+ default:
+ return EINVAL;
+ }
}
ErrorOr<NonnullOwnPtr<KString>> MasterPTY::pseudo_path(const OpenFileDescription&) const
diff --git a/Userland/Libraries/LibC/sys/ioctl_numbers.h b/Userland/Libraries/LibC/sys/ioctl_numbers.h
index 0c1448a9d9..02920b37df 100644
--- a/Userland/Libraries/LibC/sys/ioctl_numbers.h
+++ b/Userland/Libraries/LibC/sys/ioctl_numbers.h
@@ -89,6 +89,7 @@ enum IOCtlNumber {
TIOCSTI,
TIOCNOTTY,
TIOCSWINSZ,
+ TIOCGPTN,
FB_IOCTL_GET_PROPERTIES,
FB_IOCTL_GET_HEAD_PROPERTIES,
FB_IOCTL_SET_HEAD_RESOLUTION,
@@ -143,6 +144,7 @@ enum IOCtlNumber {
#define TIOCSTI TIOCSTI
#define TIOCNOTTY TIOCNOTTY
#define TIOCSWINSZ TIOCSWINSZ
+#define TIOCGPTN TIOCGPTN
#define FB_IOCTL_GET_PROPERTIES FB_IOCTL_GET_PROPERTIES
#define FB_IOCTL_GET_HEAD_PROPERTIES FB_IOCTL_GET_HEAD_PROPERTIES
#define FB_IOCTL_GET_HEAD_EDID FB_IOCTL_GET_HEAD_EDID