我正在编写一个脚本来分析使用 strace
跟踪的文件访问.
跟踪包含一些已被另一个进程中断的调用。 strace
向他们展示 <unfinished ...>
和 <... close resumed>
(在中断 close
调用的情况下)标记。
[pid 26817] 12:48:22.972737 close(449 <unfinished ...>
[pid 28708] 12:48:22.972797 fcntl(451, F_SETFD, FD_CLOEXEC <unfinished ...>
[pid 26817] 12:48:22.972808 <... close resumed> ) = 0
进程及其所有线程都被跟踪
strace -f -tt -p <pid>
手册页不确定调用何时结束。
If a system call is being executed and meanwhile another one is being called from a different thread/process then strace will try to preserve the order of those events and mark the ongoing call as being unfinished. When the call returns it will be marked as resumed.
虽然我假设,自然是 resumed
标记将指示调用现在已完成。我想问一下是不是这样。
能否将上述跟踪摘录重构为
一个
[pid 28708] 12:48:22.972797 fcntl(451, F_SETFD, FD_CLOEXEC <unfinished ...>
[pid 26817] 12:48:22.972808 close(449) = 0
还是应该重构为
B
[pid 26817] 12:48:22.972737 close(449) = 0
[pid 28708] 12:48:22.972797 fcntl(451, F_SETFD, FD_CLOEXEC <unfinished ...>
顺序在这里很重要,因为 unfinished
之间可能有多个调用和 resumed
其中之一可能会对此时即将关闭的文件执行某些操作。
最佳答案
系统调用开始时 strace
写下 close(449 <unfinished ...>
行, 并在输出 <... close resumed>
时结束 .
close
不被任何其他调用或信号中断:另一个调用由另一个进程执行,而内核正在关闭您的文件描述符。
无法知道文件描述符关闭的确切时间点;您唯一知道的是它在执行系统调用之前不会关闭,并且在系统调用完成时关闭。
关于linux - strace: <unfinished ...> 和 <... resumed> 的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24716380/