查看流程状态的实时报告


4

在Linux下,我可以top用来查看正在运行的进程的实时报告。我使用的一个重要字段是Process Status字段,它显示进程是否正在运行,僵尸,睡眠等。

我正在阅读顶级的Mac OS X联机帮助页,但我没有看到进程状态。 https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/top.1.html

是否有其他方法可以从OS X中的命令行执行此操作?我正在调试一个使用的程序fork(),因此我需要一些能够向我显示当前正在执行的进程的实时源。

Answers:


3

在OS X中,top该字段的版本称为STATE,它显示进程所处的状态。有关stuck状态的信息,请参阅:https//apple.stackexchange.com/a/58718/292

psOS X上的命令还可以显示进程状态。例如,ps aux包括该STATE字段。而PS手册页有这么一段有关领域:

 state     The state is given by a sequence of characters, for example, ``RWNA''.  The first character indicates the run state of the process:

           I       Marks a process that is idle (sleeping for longer than about 20 seconds).
           R       Marks a runnable process.
           S       Marks a process that is sleeping for less than about 20 seconds.
           T       Marks a stopped process.
           U       Marks a process in uninterruptible wait.
           Z       Marks a dead process (a ``zombie'').

           Additional characters after these, if any, indicate additional state information:

           +       The process is in the foreground process group of its control terminal.
           <       The process has raised CPU scheduling priority.
           >       The process has specified a soft limit on memory requirements and is currently exceeding that limit; such a process is (necessarily) not swapped.
           A       the process has asked for random page replacement (VA_ANOM, from vadvise(2), for example, lisp(1) in a garbage collect).
           E       The process is trying to exit.
           L       The process has pages locked in core (for example, for raw I/O).
           N       The process has reduced CPU scheduling priority (see setpriority(2)).
           S       The process has asked for FIFO page replacement (VA_SEQL, from vadvise(2), for example, a large image processing program using virtual memory to sequentially
                   address voluminous data).
           s       The process is a session leader.
           V       The process is suspended during a vfork(2).
           W       The process is swapped out.
           X       The process is being traced or debugged.

可悲的是,即便如此top -stats pstate,我也无法top展示僵尸。所以,看起来像使用ps的方式。
425nesp 2014年

0

OS X也有top命令。由于OS X是基于BSD的,因此可能存在使用差异。有关更多信息,请参阅man top

ps ax | grep 'Z'例如,您可能会发现更容易找到僵尸进程。top可能不会做你想要的。


1
OP已经阅读了第二段的手册页面
马克

干杯,马克。感谢那。答案相应更新。
Trane Francks 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.