diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-05-23 22:10:15 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-24 05:55:44 +0200 |
commit | d2ec82d4f98ce4e1afbc2cb163f83a0b91a1372f (patch) | |
tree | cb87a9697eea4b094ccbfd8d1e64f0b8b142d403 /Userland/Utilities | |
parent | 2dbc7e4ffff0eaa4b07bdc8ee3db9df3226da52f (diff) | |
download | serenity-d2ec82d4f98ce4e1afbc2cb163f83a0b91a1372f.zip |
Utilities/w: Display the TTY pseudo name in the "TTY" column
This matches the format used by `ps`.
If we cannot determine the TTY
pseudo name we fall back to the full device name, as shown previously.
Diffstat (limited to 'Userland/Utilities')
-rw-r--r-- | Userland/Utilities/w.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Utilities/w.cpp b/Userland/Utilities/w.cpp index 71c53d3c8c..04f2fa5fcb 100644 --- a/Userland/Utilities/w.cpp +++ b/Userland/Utilities/w.cpp @@ -75,6 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments) StringBuilder builder; String idle_string = "n/a"_short_string; String what = "n/a"_short_string; + StringView tty_display_name = tty; auto maybe_stat = Core::System::stat(tty); if (!maybe_stat.is_error()) { auto stat = maybe_stat.release_value(); @@ -85,6 +86,7 @@ ErrorOr<int> serenity_main(Main::Arguments) } auto tty_pseudo_name = TRY(tty_stat_to_pseudo_name(stat)); + tty_display_name = tty_pseudo_name; for (auto& process : process_statistics.processes) { if (tty_pseudo_name == process.tty.view() && process.pid == process.pgid) { what = TRY(String::from_deprecated_string(process.name)); @@ -93,7 +95,7 @@ ErrorOr<int> serenity_main(Main::Arguments) } } - outln("{:10} {:12} {:16} {:6} {}", username, tty, login_at, idle_string, what); + outln("{:10} {:12} {:16} {:6} {}", username, tty_display_name, login_at, idle_string, what); return {}; })); return 0; |