Linux查看進程的所有子進程和線程

來源:互聯網
上載者:User

得到進程的pid:
ps -ef | grep process_name | grep -v "grep" | awk '{print $2}'

查看進程的所有線程
# ps mp 6648 -o THREAD,tid
USER %CPU PRI SCNT WCHAN USER SYSTEM TID
root 0.0 - - - - - -
root 0.0 24 - - - - 6648
root 0.0 21 - - - - 6650
root 1.0 24 - - - - 14214
root 0.0 23 - futex_ - - 14216
root 0.0 22 - 184466 - - 15374
root 0.0 23 - 184466 - - 15376
root 0.0 23 - 184466 - - 15378
root 0.0 23 - 184466 - - 15380
root 0.0 23 - 184466 - - 15392
root 0.0 23 - 184466 - - 15394
root 0.0 23 - 184466 - - 15398

查看所有子進程:
# pstree -p 6648
agent_executor(6648)─┬─tar(15601)───gzip(15607)
├─{agent_executor}(6650)
├─{agent_executor}(14214)
├─{agent_executor}(14216)
├─{agent_executor}(15374)
├─{agent_executor}(15376)
├─{agent_executor}(15378)
├─{agent_executor}(15380)
├─{agent_executor}(15392)
├─{agent_executor}(15394)
└─{agent_executor}(15398)

 

查看/proc/pid/status可以看到一些進程的目前狀態:

Name: bash
State: S (sleeping)
SleepAVG: 98%
Tgid: 11237
Pid: 11237
PPid: 11235
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 256
Groups: 0 1 2 3 4 6 10
VmPeak: 66260 kB
VmSize: 66228 kB
VmLck: 0 kB
VmHWM: 1684 kB
VmRSS: 1684 kB
VmData: 456 kB
VmStk: 88 kB
VmExe: 712 kB
VmLib: 1508 kB
VmPTE: 68 kB
StaBrk: 008c3000 kB
Brk: 011b1000 kB
StaStk: 7fff8b728170 kB
Threads: 1
SigQ: 1/30222
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000010000
SigIgn: 0000000000384004
SigCgt: 000000004b813efb
CapInh: 0000000000000000
CapPrm: 00000000fffffeff
CapEff: 00000000fffffeff
Cpus_allowed: 00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000003
Mems_allowed: 1

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.