我做了test.cpp个,然后编辑了这个.

int main() {
    while(1);
}

g++ test.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

推荐答案

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

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

./a.out &

然后,您可以通过使用fg命令或通过将进程放到后台后获得的进程ID来恢复进程.

Linux相关问答推荐

排除最大FIFO大小故障

X86_64程序集中的分段故障:系统调用问题

Flutter 构建错误:';DART:JS_interop';在此平台上不可用

将(覆盖)文件移动到不同位置的同名文件夹中

操作系统信号处理循环 - 阻塞或非阻塞读取?

Rust unix 进程

将文件的一部分插入到另一个文件的特定位置

判断条件是否为假

无法在 Android Studio 中清理项目

自动化 Amazon EBS 快照 任何人在 linux 上都有一个好的脚本或解决方案

使远程目录保持最新

bash 中的线程?

如何在 Linux 中通过控制台输出启动 Tomcat?

判断 VT-x 是否已激活而无需在 Linux 中重新启动?

可以通过 SSH 连接的所有用户的列表

ngrok 如何在防火墙后工作?

如何从目录复制内容而不是符号链接?

PostgreSQL psql 终端命令

Linux 上的 NuGet:获取响应流时出错

如何用逗号而不是空格分割列表