dalance / procs

A modern replacement for ps written in Rust
MIT License
4.99k stars 109 forks source link

Exclude procs process when using sudo #606

Closed notDavid closed 5 months ago

notDavid commented 5 months ago

Hi there, fyi, not sure if it's an issue or some mis-understanding / configuration by me;

The procs process itself is only excluded when not using sudo:

$ procs test123
 PID:▲ User │ TTY CPU MEM CPU Time │ Command
            │     [%] [%]          │

$ sudo procs test123
 PID:▲ User │ TTY  CPU MEM CPU Time │ Command
            │      [%] [%]          │
 4372  root │ s004 0.0 0.0 00:00:00 │ sudo procs test123

Best, David.

-- procs 0.14.4 (installed via HomeBrew) macOS 14.3.1

dalance commented 5 months ago

This is expected behaviour. The 4372 is sudo process, and the sudo process will launch procs. show_self = false option hides the self procs process only, so sudo process will be shown. If show_self = false are given, the result of sudo procs will be like below:

$ sudo procs test123
 PID:▲ User │ TTY  CPU MEM CPU Time │ Command
            │      [%] [%]          │
 4372  root │ s004 0.0 0.0 00:00:00 │ sudo procs test123
 4373  root │ s004 0.0 0.0 00:00:00 │ procs test123
notDavid commented 5 months ago

Thank you for explaining @dalance

Would you please consider to implement a feature to add a show_self_sudo = false setting?

Because currently if i want to watch some process, for example the borg processes with sudo procs --watch --tree borg, then the result is cluttered with multiple lines containing the entire tree of the sudo procs process (including the login shell, terminal program, etc.).

All of this is not relevant, and it makes it more difficult to read the result...

Thank you!

dalance commented 5 months ago

I'll add show_self_parents option at #607. It suppress to show the parents processes which have self as the only child.

For example, in the following process tree, "bash - sudo - procs" will be hidden. The root "bash" will be shown because it has other process which are not related to procs as the children.

How about it?

notDavid commented 5 months ago

@dalance That would be the perfect solution i think.

dalance commented 5 months ago

I've released v0.14.5.

notDavid commented 5 months ago

Tested, and it's working nicely now. Thank you for the quick fix!