这是pstree(1)
通过使用一个选项来仅显示特定 PID 的树并提供当前进程的 PID($$
在 Bash 中)来支持的,该选项在随 Debian 分发的 Werner Almesberger 的 GPL 许可版本和 Fred 的 BSD 版本之间命名不同Hucht 随 MacOS 分发。
在 Debian/Ubuntu 上: pstree -s $$
init???gnome-terminal???bash???pstree
Run Code Online (Sandbox Code Playgroud)
-s
选项摘要:
-s Show parent processes of the specified process.
Run Code Online (Sandbox Code Playgroud)在 MacOS 上: pstree -p $$
-+= 00001 root /sbin/launchd
\-+= 25706philipbranning/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
\-+= 25716 root login -pfl philipbranning /bin/bash -c exec -la bash /bin/bash
\-+= 25722 philipbranning -bash
\-+= 32456 philipbranning pstree -p 25722
\--- 32457 root ps -axwwo user,pid,ppid,pgid,command
Run Code Online (Sandbox Code Playgroud)
-p
选项摘要:
-p pid show only branches containing process <pid>
Run Code Online (Sandbox Code Playgroud)这是您的 MacOS 别名:
alias psme='pstree -p $$'
Run Code Online (Sandbox Code Playgroud)
我相信通过谷歌搜索,您可以找到如何获取和下载pstree
Mac.但是,你可以做一个穷人的版本,使用ps
和ppid
.
例如
ps -eo ppid,pid,cmd | awk '{p[$1]=p[$1]","$3}END{ for(i in p) print i, p[i]}'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17904 次 |
最近记录: |