Tim*_*Tim 5 linux ps system-v thread
在 ps 的联机帮助页中
tid TID the unique number representing a dispatchable
entity (alias lwp, spid). This value may also
appear as: a process ID (pid); a process group
ID (pgrp); a session ID for the session leader
(sid); a thread group ID for the thread group
leader (tgid); and a tty process group ID for
the process group leader (tpgid).
tgid TGID a number representing the thread group to which
a task belongs (alias pid). It is the process
ID of the thread group leader.
Run Code Online (Sandbox Code Playgroud)
在 Ubuntu 中,对于用户进程和内核线程(我运行),tid 和 tgid 似乎总是与 pid 相同,ps -o pid,tid,tgid,cmd
这在 Linux 中是这样吗?为什么?
在其他 Unix(例如 System V 或 BSD)中也是如此吗?
谢谢。
您需要任务ps
来显示线程信息;否则它只列出进程:
ps -eL -o pid,tid,comm | awk '$1 != $2'\n
Run Code Online (Sandbox Code Playgroud)\n\n将显示除每个 process\xe2\x80\x99 主线程之外的所有线程,即进程表中 pid 和 tid 不同的条目。重要的选项是-L
:如果没有这个选项,ps
将仅列出 pid 和 tid 相同的条目。
在 FreeBSD 上,等效选项是-H
. 我还没有检查过其他 BSD 或 System V。