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:
pax> sleep 3600 &
pax> jobs
you will see output like:
[1]+ Running sleep 3600 &
Then, you can bring that job back into the foreground by using:
pax> fg %1
sleep 3600
(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 is SIGCONT
(to continue):
pax> fg %1
sleep 3600
^Z
[1]+ Stopped sleep 3600
pax> jobs
[1]+ Stopped sleep 3600
pax> kill -CONT %1
pax> jobs
[1]+ Running sleep 3600 &
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.