为什么 strace -f 无法跟踪 | 之后的 child 进度?
Why strace -f can't trace the child progress after |?
我想看看当我运行一个命令时系统调用会发生什么,但似乎那些命令在|之后不能显示?喜欢:
strace -f cat a.txt| cat
好像strace和-f perimeter可以显示整个过程。我认为最后一部分是在 fork 创建的 child 进度中。为什么以及如何制作它?
来自 strace
手册(强调我的)。
-f Trace child processes as they are created by
currently traced processes as a result of the fork(2),
vfork(2) and clone(2) system calls.
您案例中的跟踪进程是第一个 cat
进程。第二个 cat
进程 不是 第一个 cat
进程的子进程。分叉由 shell.
完成
一种实现你想要的方法是跟踪 shell:
strace -f bash -c "cat a.txt| cat"
我想看看当我运行一个命令时系统调用会发生什么,但似乎那些命令在|之后不能显示?喜欢:
strace -f cat a.txt| cat
好像strace和-f perimeter可以显示整个过程。我认为最后一部分是在 fork 创建的 child 进度中。为什么以及如何制作它?
来自 strace
手册(强调我的)。
-f Trace child processes as they are created by currently traced processes as a result of the fork(2), vfork(2) and clone(2) system calls.
您案例中的跟踪进程是第一个 cat
进程。第二个 cat
进程 不是 第一个 cat
进程的子进程。分叉由 shell.
一种实现你想要的方法是跟踪 shell:
strace -f bash -c "cat a.txt| cat"