Hi Marc,

On Sun, 8 Feb 2026 at 19:21, Marc Haber <[email protected]>
wrote:

Actual Output:
> |-bash,223670
> |   `-git,229284 log --max-count=1
> |       `-sh,229285 -c less -F -R -X less -F -R -X
> |           `-less,229286 -F -R -X
>
> The command string less -F -R -X appears twice on the sh line
>
[...]

> Running `ps` on the `less` process confirms only one instance exists
> with correct arguments:
>
> $ ps 229286
>    PID TTY      STAT   TIME COMMAND
> 229286 pts/10   S+     0:00 less -F -R -X
>

The line with the duplicate is 229285 not 229286. pstree correctly shows
the same as ps for 229286.
Try doing the same ps command for 229285.

$ pstree -apl | grep -A 3 gi[t]
  |   |   |   `-git,7392 log --max-count=45
  |   |   |       `-sh,7393 -c less -A -F -X less -A -F -X
  |   |   |           `-less,7394 -A -F -X
  |   |   |-bash,5332
$ ps 7393 7394
    PID TTY      STAT   TIME COMMAND
   7393 pts/0    S+     0:00 /bin/sh -c less -A -F -X less -A -F -X
   7394 pts/0    S+     0:00 less -A -F -X

The duplicates are what the kernel is reporting, the ^@ is nul which
separates command line options.
$ cat -e /proc/7393/cmdline
/bin/sh^@-c^@less -A -F -X^@less -A -F -X^@

So yes, I totally agree it looks strange, but the strangeness is actually
there!

Perhaps this is a wishlist bug and you want pstree to change the output if
it is duplicated?
The big problem with that is, pstree and ps do not change what they get and
I don't see a bulletproof
way of pstree knowing when is the right time to remove duplicates.

I'd probably get mirrored bug reports, like "pstree reports prog -foo but
ps shows prog -foo -foo".

 - Craig

Reply via email to