ps aux 输出
- R (TASK_RUNNING):运行状态,即包括了上图中的就绪状态和运行状态
- S (TASK_INTERRUPTIBLE):可中断的睡眠状态,即上图中的阻塞状态。在这个状态下进程是可被中断的,即收到信号之后可以执行信号处理函数
- D (TASK_UNINTERRUPTIBLE):不可中断的睡眠状态。磁盘IO时会出现这种状态,在此状态下,进程是不能被中断的,即不能响应信号。但是可以响应外部硬件中断
- T (TASK_STOPPED):停止状态。记得是大写的T。当进程收到SIGSTOP信号后就处于停止状态,可以发送SIGCONT信号让进程继续运行
- X (TASK_DEAD - EXIT_DEAD):退出状态(死亡状态)。进程即将被销毁,通常是在父进程中设置SIGCHLD信号的handler为SIG_IGN,显式忽略了SIGCHLD信号。在使用ps命令查看进程状态时很难捕捉到这种状态
- Z (TASK_DEAD - EXIT_ZOMBIE):僵尸状态。子进程先于父进程退出,并且父进程没有调用wait或waitpid回收子进程。此时子进程即处于僵尸状态
- t(TASK_TRACED):跟踪状态,记得是小写的t,和停止状态只是大小写的区别。当利用gdb调试某个程序,程序停留在某个断点处时,就处于跟踪状态。
此外,以下是一些其他标识符的含义:
- <:高优先级
- N:低优先级
- L:有些页被锁进内存
- s:包含子进程
- +:位于后台的进程组
- l:多线程,克隆线程(使用CLONE_THREAD,类似于NPTL pthreads)
man ps
PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe
the state of a process:
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