Linux实用程序" strace"显示运行strace后启动的系统调用列表。我怎样才能看到在当前时刻按进程运行的系统调用?在strace开始之前。
答案 0 :(得分:2)
proc
提供了一些有关内核当前正在做什么的信息"对于"一个过程
/proc/${pid}/syscall
/proc/${pid}/stack
更多信息:
答案 1 :(得分:1)
假设您知道进程的PID,则只需使用strace即可实时跟踪所有正在执行的系统调用。
strace -p PID
答案 2 :(得分:0)
你发现使用ps
:
ps -p PID_OF_PROC -ocmd,stat,wchan
wchan
是关键所在。来自man ps
:
wchan WCHAN 进程正在休眠的内核函数的名称," - "如果进程正在运行,或者a " *"如果进程是多线程的,并且ps没有显示线程。
处理状态代码 以下是s,stat和state输出说明符(标题" STAT"或" S")将显示的不同值 过程的状态:
D uninterruptible sleep (usually IO) R running or runnable (on run queue) S interruptible sleep (waiting for an event to complete) T stopped by job control signal t stopped by debugger during the tracing W paging (not valid since the 2.6.xx kernel) X dead (should never be seen) Z defunct ("zombie") process, terminated but not reaped by its parent For BSD formats and when the stat keyword is used, additional characters may be displayed: < high-priority (not nice to other users) N low-priority (nice to other users) L has pages locked into memory (for real-time and custom IO) s is a session leader l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) + is in the foreground process group