linux - 在 Strace 命令中查询 PID

标签 linux strace

我执行以下 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 的 child 吗?谁在创造它们?

谢谢。

最佳答案

What are these extra PID's ? Are these the children of 13221 ?

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

How to know which of these are threads

如果你运行 ls /proc/<PID>/task对于您的进程,您将获得进程中所有线程的 PID(包括主线程的 PID)。

与运行pstack相比,需要获取线程PID时更简单对于相同的过程。 pstack实际上是一个 gdb脚本,它在附加时停止进程。所以只运行 ls /proc/<PID>/task 更简单

关于linux - 在 Strace 命令中查询 PID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25937323/

相关文章:

c++ - open()返回结果码的区别: 25 vs 3?

javascript - Node.js 100% CPU - gettimeofday 调用

linux - 无法理解进程的 strace

linux - 使用 xargs 解压多个文件

linux - cygnus 服务未作为服务启动

c++ - C/C++ TensorFlow hello_tf.c :(. text+0xa): 未定义对 `TF_Version' 的引用

c++ - int main 的返回代码 - 有上限吗?

linux - wmctrl 打开没有焦点的窗口

linux - 如何在 Linux 中跟踪每个文件的 IO 操作?

macos - 使用命令行工具确定 OSX 上的进程被什么阻塞?