Which signal should I send to a background process to move it foreground? SIGTTIN, SIGTOU or...?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
It's not signals which directly control whether jobs are foreground or background. The jobs are under the control of a shell (usually).
For example, under
bash
, if you execute:you will see output like:
Then, you can bring that job back into the foreground by using:
(and the terminal waits).
Using CTRLZ does send a signal to the process (
SIGSTOP
) as well as putting it into the background but the only signal that can change that isSIGCONT
(to continue):That will instruct the process to start running again but it doesn't bring it into the foreground. For that, you need the
fg
command.It's probably best to think of signals (which affect the process) and foreground/background (which affect the shell that started the process by determining whether it waits for it, amongst other things) separately.
Assuming you are on Unix and started the process from a shell you could type the following
gurudoglu. I think your request's response is here :
There is no way (In any OS I know of yet) to use a signal to bring a process to the foreground.
I believe you can only bring a process to the foreground using
fg
Foreground is only relevant in the context of a console, and a signal cannot tell the process what console to foreground to...