I have a process originally running in the foreground. I suspended by Ctrl+Z, and then resume its running in the background by bg <jobid>
.
I wonder how to suspend a process running in the background?
How can I bring a background process to foreground?
Edit:
The process outputs to stderr, so how shall I issue the command fg <jobid>
while the process is outputting to the terminal?
Best Answer
As Tim said, type
fg
to bring the last process back to foreground.If you have more than one process running in the background, do this:
fg %3
to bring thevim 23
process back to foreground.To suspend the process running in the background, use:
The SIGSTOP signal stops (pauses) a process in essentially the same way Ctrl+Z does.
example:
kill -STOP %3
.sources: How to send signals to processes in Linux and Unix and How to manage background and foreground jobs.