diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index abfa3cbd12..08be0a82ec 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -495,6 +495,12 @@ private: TRY(process_object.add("uid", process.uid().value())); TRY(process_object.add("gid", process.gid().value())); TRY(process_object.add("ppid", process.ppid().value())); + if (process.tty()) { + auto tty_pseudo_name = TRY(process.tty()->pseudo_name()); + TRY(process_object.add("tty", tty_pseudo_name->view())); + } else { + TRY(process_object.add("tty", "")); + } TRY(process_object.add("nfds", process.fds().with_shared([](auto& fds) { return fds.open_count(); }))); TRY(process_object.add("name", process.name())); TRY(process_object.add("executable", process.executable() ? TRY(process.executable()->try_serialize_absolute_path())->view() : ""sv)); diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index defcf346ae..f916a330f3 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -54,6 +54,11 @@ SlavePTY::~SlavePTY() dbgln_if(SLAVEPTY_DEBUG, "~SlavePTY({})", m_index); } +ErrorOr> SlavePTY::pseudo_name() const +{ + return KString::formatted("pts:{}", m_index); +} + void SlavePTY::echo(u8 ch) { if (should_echo_input()) { diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index 15c576471e..0c688c73a8 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -27,6 +27,7 @@ public: private: // ^TTY + virtual ErrorOr> pseudo_name() const override; virtual ErrorOr on_tty_write(const UserOrKernelBuffer&, size_t) override; virtual void echo(u8) override; diff --git a/Kernel/TTY/TTY.h b/Kernel/TTY/TTY.h index 7f5c7e6ad3..a093120b6e 100644 --- a/Kernel/TTY/TTY.h +++ b/Kernel/TTY/TTY.h @@ -46,6 +46,8 @@ public: void set_default_termios(); void hang_up(); + virtual ErrorOr> pseudo_name() const = 0; + protected: virtual ErrorOr on_tty_write(const UserOrKernelBuffer&, size_t) = 0; void set_size(unsigned short columns, unsigned short rows); diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index ec7ad35c90..9a143918c2 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -102,6 +102,11 @@ void VirtualConsole::set_graphical(bool graphical) m_graphical = graphical; } +ErrorOr> VirtualConsole::pseudo_name() const +{ + return KString::formatted("tty:{}", m_index); +} + UNMAP_AFTER_INIT NonnullRefPtr VirtualConsole::create(size_t index) { auto virtual_console_or_error = DeviceManagement::try_create_device(index); diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index 3401b5657e..e3a9a22ea1 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -89,6 +89,7 @@ private: virtual void on_key_pressed(KeyEvent) override; // ^TTY + virtual ErrorOr> pseudo_name() const override; virtual ErrorOr on_tty_write(const UserOrKernelBuffer&, size_t) override; virtual void echo(u8) override;