Advertisement
Guest User

Untitled

a guest
May 28th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.53 KB | None | 0 0
  1. #bin/bash.sh
  2.  
  3.  
  4. PS=$(ps h -o ppid,pid= $1)
  5. #a beinhaltet 2 Slots; 0=PPID, 1=PID
  6. a=( $PS )
  7. CURR_PARENT=${a[0]}
  8. PS_NAME=$(ps h -p $1 -o comm)
  9. echo "Current Prozess: $1($PS_NAME), Parent: $CURR_PARENT"
  10.  
  11. while [ $CURR_PARENT != 1 ]
  12. do
  13. # The new pid is the current parent
  14. PS=$(ps h -o ppid,pid= $CURR_PARENT)
  15. a=( $PS )
  16. CURR_PARENT=${a[0]}
  17. PS_NAME=$(ps h -p ${a[1]} -o comm)
  18. echo "Next Prozess: $TMP($PS_NAME), Parent: $CURR_PARENT"
  19. done
  20.  
  21. PS_NAME=$(ps h -p 1 -o comm)
  22.  
  23. #Name of process 1
  24. echo "Last Process: 1 ($PS_NAME)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement