gpt4 book ai didi

linux - c++进程状态中的+是什么意思

转载 作者:行者123 更新时间:2023-12-05 02:25:26 27 4
gpt4 key购买 nike

我制作了 test.cpp 并编译了它。

int main() {
while(1);
}

g++ 测试.cpp

ps -aux | grep a.out.

进程状态a.out是R+

是的。当然,这个过程会无限运行。

但是,我不明白 +

ps手册中,+在前台进程组中。

不知道a.out在前台进程组是什么意思

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)
I Idle kernel thread
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

最佳答案

它基本上意味着进程在终端 session 中执行,占用它,用户可以直接访问它。后台进程在没有直接用户交互的情况下运行。主要在您想要继续使用终端 session 但又需要运行时间要求很高的计算时使用。

您可以通过在启动命令后提供 & 符号来更改程序的这种状态:

./a.out &

然后您可以使用 fg 命令或通过将进程置于后台后获得的进程 ID 恢复您的进程。

关于linux - c++进程状态中的+是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74610356/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com