2017-03-08 61 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