Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I send SIGCONT to a running process?

Tags:

c

linux

signals

I know that SIGCONT continues a process previously stopped by SIGSTOP. Can I use SIGCONT multiple times without a SIGSTOP ? i,e , below sequence is valid ?

SIGSTOP to process A : The process stops
SIGCONT to process A : Process resumes
SIGCONT to process A : Process already runs - this SIGCONT has no effect 
SIGCONT to process A : Process already runs - this SIGCONT has no effect 
...
SIGSTOP to process A : The process stops
SIGCONT to process A : Process resumes
like image 576
Lunar Mushrooms Avatar asked Aug 20 '12 10:08

Lunar Mushrooms


People also ask

How do I send a SIGCONT signal?

Regardless of user ID, a process can always send a SIGCONT signal to a process that is a member of the same session (same session ID) as the sender. You can use either signal() or sigaction() to specify how a signal will be handled when kill() is invoked. A process can use kill() to send a signal to itself.

Can SIGCONT be handled?

You can use a handler for SIGCONT to make a program do something special when it is stopped and continued—for example, to reprint a prompt when it is suspended while waiting for input. The SIGSTOP signal stops the process. It cannot be handled, ignored, or blocked.

Can SIGCONT be caught?

SIGTHSTOP and SIGTHCONT cannot be caught or ignored; they always take effect.

How do you use SIGSTOP and SIGCONT?

In short, SIGSTOP tells a process to “hold on” and SIGCONT tells a process to “pick up where you left off”. This can work really well for rsync jobs since you can pause the job, clear up some space on the destination device, and then resume the job.


1 Answers

You can do it. TLPI says:

When sent to a stopped process, this signal causes the process to resume (i.e., to be rescheduled to run at some later time). When received by a process that is not currently stopped, this signal is ignored by default. A process may catch this signal, so that it carries out some action when it resumes.

APUE:

Note that the default action for SIGCONT is to continue the process, if it is stopped; otherwise, the signal is ignored.

like image 119
cnicutar Avatar answered Oct 09 '22 05:10

cnicutar