我执行以下strace命令以获取有关PID 13221的数据
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的孩子吗?谁在创造它们?
感谢。
答案 0 :(得分:1)
这些额外的PID是什么?这些是13221的孩子吗?
它一定是你程序的线程。您使用了" -f"在strace中,这也是线程也受到监控的原因。
如何知道哪些是线程
如果为进程运行ls /proc/<PID>/task
,您将获得进程中所有线程的PID(包括主线程的PID)。
当您需要获取线程PID与运行同一进程的pstack
进行比较时,更简单。 pstack
实际上是一个gdb
脚本,它会在附加时停止进程。因此,运行ls /proc/<PID>/task