2014-09-19 86 views
1

我执行与获取有关PID数据的意图以下strace的命令13221质疑PID的

strace -fF -tT -all -o abc.txt -p 13221 

然而,当命令执行和完成我得到的输出象下面这样:

Process 13221 attached with 12 threads - interrupt to quit 
Process 13252 attached 
Process 13253 attached (waiting for parent) 
Process 13253 resumed (parent 13252 ready) 
Process 13252 suspended 
Process 13252 resumed 
Process 13253 detached 
Process 13252 detached 
Process 13232 detached 
Process 13228 detached 
Process 13225 detached 
Process 13222 detached 
Process 13221 detached 

这些额外的PID是什么?这些是13221的孩子吗?谁在创造它们?

谢谢。

+1

它一定是你的程序的线程。你已经使用“-f”。请添加到您的问题这个信息:cat/proc/13221/tasks – 2014-09-19 16:43:21

+0

我尝试了一个不同的过程,我做了一个strace,并在/ proc/PID /任务/这些ID中的一些存在。这些线程ID或进程id?我认为它是愚蠢的,它们应该是流程,因为它们在/ proc/ – Geek 2014-09-19 18:28:40

+1

至于'这些线程ID或进程ID'。在Linux上,线程是进程。他们也有PID – 2014-09-19 18:40:13

回答

1

什么是这些额外的PID?这些是13221的孩子吗?

它一定是你程序的线程。你已经在strace中使用了“-f”,这就是为什么线程也被监控的原因。

如何知道哪些是线程

如果您运行ls /proc/<PID>/task你的过程中,你会得到所有线程的PID在过程(包括主线程的PID)。

当您需要获取线程PID并与运行pstack进行比较时,执行相同的过程会更简单。 pstack实际上是一个gdb脚本,它在连接时会停止一个进程。所以它只是运行更简单ls /proc/<PID>/task