当我这样做时:
sudo strace -p PID 2>&1 | grep -v "recvmsg"
grep 匹配它应该匹配的行,但是当我这样做时:
sudo strace -p PID|grep -v "recvmsg"
它仍然显示所有调用。 这是为什么?
最佳答案
这是因为 strace 将其所有输出写入 stderr,而不是 stdout。管道重定向 stdout,而不是 stderr。因此,在通过管道传输到 grep 之前,您需要将 strace 的 stderr 重定向到 stdout。
关于linux - strace 上的 grep 仅使用 stderr 到 stdout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23151186/