Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working as expected when ppid greater than pid #6

Open
joknarf opened this issue Jul 27, 2020 · 1 comment
Open

not working as expected when ppid greater than pid #6

joknarf opened this issue Jul 27, 2020 · 1 comment

Comments

@joknarf
Copy link

joknarf commented Jul 27, 2020

When child pid less than its parent, the ps command will display child before parent (see 375 1051 bash line in example)

it seems bad supposition in format_process_trees :

# Parent always comes before child
# ps -ef -o pid,ppid,args
  PID  PPID COMMAND
    1     0 /init
    6     1 /init
    7     6 /init
    8     7 -bash
  375  1051 bash
  383   375 bash
  396   383 ps -e -o pid,ppid,args
  636     1 /init
  637   636 /init
  638   637 -bash
 1011     8 bash
 1019  1011 bash
 1027  1019 bash
 1035  1027 bash
 1051  1035 bash

# ./pst.py -w
  PID  COMMAND
    1  /init
    6   \_ /init
    7   \_ /init
    8   |       \_ -bash
 1011   |           \_ bash
 1019   |               \_ bash
 1027   |                   \_ bash
 1035   |                       \_ bash
 1051   |                           \_ bash
  636   \_ /init
  637   \_ /init
  638           \_ -bash
  375  bash                                 <====== is child of 1051 !
  383   \_ bash
  392   \_ python ./pst.py -w
  393           \_ ps -e l

# pstree -ap
init,1
  ├─init,6
  │   └─init,7
  │       └─bash,8
  │           └─bash,1011
  │               └─bash,1019
  │                   └─bash,1027
  │                       └─bash,1035
  │                           └─bash,1051
  │                               └─bash,375
  │                                   └─bash,383
  │                                       └─pstree,407 -ap
  ├─init,636
  │   └─init,637
  │       └─bash,638
  └─{init},5
@topunix
Copy link
Owner

topunix commented Aug 21, 2020

Thanks, I will take a look, when I have a chance. I appreciate your reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants