Skip to content

Commit

Permalink
ps: Show "/dev/pts/0" as "pts/0" instead of "0"
Browse files Browse the repository at this point in the history
Also tweak the alignment of the output a bit.
  • Loading branch information
awesomekling committed Nov 26, 2019
1 parent aa49419 commit 9a6d506
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Userland/ps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ int main(int argc, char** argv)
(void)argc;
(void)argv;

printf("PID TPG PGP SID OWNER STATE PPID NSCHED FDS TTY NAME\n");
printf("PID TPG PGP SID UID STATE PPID NSCHED FDS TTY NAME\n");

auto all_processes = CProcessStatisticsReader::get_all();

for (const auto& it : all_processes) {
const auto& proc = it.value;
auto tty = proc.tty;

if (tty != "notty")
tty = strrchr(tty.characters(), '/') + 1;
if (tty.starts_with("/dev/"))
tty = tty.characters() + 5;
else
tty = "n/a";

printf("%-3u %-3u %-3u %-3u %-4u %-10s %-3u %-9u %-4u %-4s %s\n",
printf("%-3u %-3u %-3u %-3u %-3u %-11s %-3u %-9u %-3u %-5s %s\n",
proc.pid,
proc.pgid,
proc.pgp,
Expand Down

0 comments on commit 9a6d506

Please sign in to comment.