linux - strace: <unfinished ...> 和 <... resumed> 的顺序

标签 linux strace

我正在编写一个脚本来分析使用 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/

相关文章:

python - strace输出处理

linux - 什么可以使程序在 `strace` 内表现不同?

php - 跨操作系统中的 Web 斜杠问题

c++ - Linux 上的 Chilitags 编译

c - 了解进程的执行环境

android - "strace -p pid"给出 "attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted"

linux - 如何跟踪在 Ubuntu Linux 中读/写到磁盘的总数据(包括元数据)?

linux - 使用正则表达式对文件运行 awk

linux - 如何使用 ff 包加载大 csv?

python - ipython 内核在 16gb 的 linux 盒子中最大容量为 3gb?