summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-05-14 13:44:40 +0100
committerAndreas Kling <kling@serenityos.org>2023-05-16 12:54:18 +0200
commita6e701a67bf9d21ede5ccecbce3b3c9fef6ce8c4 (patch)
tree580bfa9d54506b1d60f37ac18b87ad49c3b3f716 /Userland/Utilities
parentafb55d9fd8af4566433c907c3069a65f660d6d48 (diff)
downloadserenity-a6e701a67bf9d21ede5ccecbce3b3c9fef6ce8c4.zip
ps: Add the `-a` option, to list all processes associated with terminals
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/ps.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/Userland/Utilities/ps.cpp b/Userland/Utilities/ps.cpp
index bda5e143c7..75195171cd 100644
--- a/Userland/Utilities/ps.cpp
+++ b/Userland/Utilities/ps.cpp
@@ -54,10 +54,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
bool every_process_flag = false;
+ bool every_terminal_process_flag = false;
bool full_format_flag = false;
StringView pid_list;
Core::ArgsParser args_parser;
+ args_parser.add_option(every_terminal_process_flag, "Show every process associated with terminals", nullptr, 'a');
args_parser.add_option(every_process_flag, "Show every process", nullptr, 'A');
args_parser.add_option(every_process_flag, "Show every process (Equivalent to -A)", nullptr, 'e');
args_parser.add_option(full_format_flag, "Full format", nullptr, 'f');
@@ -140,8 +142,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto const& process : processes) {
auto tty = TRY(String::from_deprecated_string(process.tty));
- if (!every_process_flag && tty != this_pseudo_tty_name)
+ if (every_process_flag) {
+ // Don't skip any.
+ } else if (every_terminal_process_flag) {
+ if (tty.is_empty())
+ continue;
+ } else if (tty != this_pseudo_tty_name) {
continue;
+ }
Vector<String> row;
TRY(row.try_resize(columns.size()));