mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
ps: Sort output by PID :^)
This commit is contained in:
parent
a1e133cc6b
commit
873eb47d2b
1 changed files with 7 additions and 4 deletions
|
@ -1,9 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/QuickSort.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/ProcessStatisticsReader.h>
|
#include <LibCore/ProcessStatisticsReader.h>
|
||||||
|
@ -99,11 +100,13 @@ int main(int argc, char** argv)
|
||||||
print_column(column, column.title);
|
print_column(column, column.title);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
auto all_processes = Core::ProcessStatisticsReader::get_all();
|
auto processes = Core::ProcessStatisticsReader::get_all();
|
||||||
if (!all_processes.has_value())
|
if (!processes.has_value())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (auto const& process : all_processes.value()) {
|
quick_sort(processes.value(), [](auto& a, auto& b) { return a.pid < b.pid; });
|
||||||
|
|
||||||
|
for (auto const& process : processes.value()) {
|
||||||
auto tty = process.tty;
|
auto tty = process.tty;
|
||||||
|
|
||||||
if (!every_process_flag && tty != this_tty)
|
if (!every_process_flag && tty != this_tty)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue