ps 的控制终端输出列出了“Ss+”。我如何确定这些代码的含义?我尝试翻阅ps手册,这是一份30页的文档,我没有找到任何解释。
答案1
从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
答案2
tt
从ps
输出中查找列并使用tty
命令,如下所示:
$ps ax |more
PID TT STAT TIME COMMAND
1 ?? Ss 4:58.84 /sbin/launchd
66 ?? Ss 1:05.03 /usr/sbin/syslogd
67 ?? Ss 0:21.62 /usr/libexec/UserEventAgent (System)
$ps ax |grep bash
81939 s000 S+ 0:00.09 -bash
82152 s001 S 0:00.04 -bash
82228 s001 S+ 0:00.00 grep -I bash
$tty
/dev/ttys001
$ps ax |grep offlineimap-load
82261 s000 S+ 0:00.02 /bin/bash /Users/pbarganski/Documents/bin/offlineimap-load
82417 s001 R+ 0:00.01 grep -i offlineimap-load
从上面,tty
命令告诉我当前所在的终端 - 终端's000'在这种情况下。
从最后一个命令中,您会注意到该grep -i
命令是从终端运行的s001,但是,我当前的终端窗口离线imap加载脚本正在从控制终端运行s000- 我的第一个终端会话 - 在本例中,只是terminal.app 中的第一个选项卡终端。