2017-03-08 82 views
1

Linux实用程序“strace”显示strace运行后启动的系统调用列表。我如何看到按流程在当前运行的系统调用? strace开始之前。如何查看按进程在当前时间执行的系统调用?

+0

您打开控制台窗口,并开始输入/ usr/sbin目录....宕当前时间已经过去,它已经下一刻!错过了!下一次比现在更早开始一段时间! –

+0

我同意。我将重新阐述我的问题:如何查看进程正在执行的系统调用? –

回答

0

你发现使用ps

ps -p PID_OF_PROC -ocmd,stat,wchan 

wchan是这里的关键。从man ps

WCHAN WCHAN内核函数中的过程中处于睡眠状态,一个名“ - ”如果正在运行的进程,或 “*”,如果进程是多线程和ps不显示线程。


PROCESS状态代码 这里有不同的值,该S,STAT和状态输出说明符(标头“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