2019-06-07 09:49:31 +00:00
|
|
|
#include <LibCore/CFile.h>
|
2019-07-17 19:24:47 +00:00
|
|
|
#include <LibCore/CProcessStatisticsReader.h>
|
2019-06-07 09:49:31 +00:00
|
|
|
#include <fcntl.h>
|
2018-11-17 14:56:09 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
2018-10-23 09:57:38 +00:00
|
|
|
|
2018-11-09 09:18:04 +00:00
|
|
|
int main(int argc, char** argv)
|
2018-10-23 09:57:38 +00:00
|
|
|
{
|
2019-06-07 09:49:31 +00:00
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2019-06-02 10:07:24 +00:00
|
|
|
|
2019-11-26 13:57:11 +00:00
|
|
|
printf("PID TPG PGP SID UID STATE PPID NSCHED FDS TTY NAME\n");
|
2019-07-17 19:24:47 +00:00
|
|
|
|
|
|
|
auto all_processes = CProcessStatisticsReader::get_all();
|
|
|
|
|
|
|
|
for (const auto& it : all_processes) {
|
|
|
|
const auto& proc = it.value;
|
|
|
|
auto tty = proc.tty;
|
|
|
|
|
2019-11-26 13:57:11 +00:00
|
|
|
if (tty.starts_with("/dev/"))
|
|
|
|
tty = tty.characters() + 5;
|
2019-07-17 20:38:45 +00:00
|
|
|
else
|
|
|
|
tty = "n/a";
|
2019-07-17 19:24:47 +00:00
|
|
|
|
2019-11-26 13:57:11 +00:00
|
|
|
printf("%-3u %-3u %-3u %-3u %-3u %-11s %-3u %-9u %-3u %-5s %s\n",
|
2019-07-17 19:24:47 +00:00
|
|
|
proc.pid,
|
|
|
|
proc.pgid,
|
|
|
|
proc.pgp,
|
|
|
|
proc.sid,
|
|
|
|
proc.uid,
|
2019-11-26 20:25:45 +00:00
|
|
|
proc.threads.first().state.characters(),
|
2019-07-17 19:24:47 +00:00
|
|
|
proc.ppid,
|
2019-11-26 20:25:45 +00:00
|
|
|
proc.threads.first().times_scheduled,
|
2019-07-17 19:24:47 +00:00
|
|
|
proc.nfds,
|
|
|
|
tty.characters(),
|
|
|
|
proc.name.characters());
|
2018-10-23 09:57:38 +00:00
|
|
|
}
|
2019-07-17 19:24:47 +00:00
|
|
|
|
2018-10-23 09:57:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|