将其置于后台后,在 Linux 上更改回正在运行的进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7235185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 05:55:56  来源:igfitidea点击:

Change back into a running process on Linux after you put it into the background

linuxprocessbackground

提问by Frank Vilea

I have spawned a process with another application. I can see that it is running with:

我用另一个应用程序生成了一个进程。我可以看到它正在运行:

ps -ef

ps -ef

How can I switch into that process as if I started it manually myself by entering the command into the console?

如何通过在控制台中输入命令来切换到该进程,就像我自己手动启动它一样?

采纳答案by Fredrik Pihl

If it's started from current shell, use standard job-control e.g.

如果它是从当前 shell 启动的,请使用标准作业控制,例如

$ jobs

$ gedit &
[1] 3341

$ jobs
[1]+  Running                 gedit &

$ fg %1
gedit

回答by thiton

Basically, you can only manage processes with job control that are children of your current shell, that is, jobs started by the shell you are working with. If you did start and background the process with your current shell, fgand the other job control options will work. If not, you cannot manage the job with the shell.

基本上,您只能使用作为当前 shell 的子级的作业控制来管理进程,即由您正在使用的 shell 启动的作业。如果您确实使用当前 shell 启动并后台处理该进程,fg则其他作业控制选项将起作用。否则,您将无法使用 shell 管理作业。

The mostly used "workaround" (actually much more powerful than the shell) is GNU screen.

最常用的“解决方法”(实际上比 shell 强大得多)是 GNU screen