LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Signalling suspended process through CTRL-Z (http://www.linuxquestions.org/questions/linux-kernel-70/signalling-suspended-process-through-ctrl-z-4175425814/)

greenday 09-05-2012 01:56 PM

Signalling suspended process through CTRL-Z
 
Hello,


Each process has always one of the five states TASK_RUNNING, TASK_INTERRUPTIBLE, TASK_UNINTERRUPTIBLE, TASK_STOPPED, TASK_ZOMBIE.

If the running process(TASK_RUNNING) is suspended using Ctrl-Z,
a) which state does it go to - TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE?
b) User can re-run(TASK_RUNNING) this suspended process by bg(background), fg(foreground) or explcitly sending CONT signal. Are these only available means to wake the suspended process? OR kernel can wake these process in other events also? (May be suspended process has registered timer handler and timer pops after the process has been suspended by CTRL-Z, resulting in waking up the process and running the timer handler and stay in TASK_RUNNING state or go back to SLEEP(TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE) state.


Thanks :-\

Ygrex 09-06-2012 11:40 PM

1. Task_stopped

greenday 09-18-2012 10:21 AM

Thanks Ygrex.

While studying signal further, I noticed in one instance where I sent a process SIGCONT signal using kill - kill(process_id, SIGCONT) and process entered in STOPPED state and kill system call did not return.

The program I was trying is to let the process run when it receives the SIGTSTP. So I registered the handler for the SIGTSTP signal and in this handler, the process sent SIGCONT signal using kill() system call. Instead of continuing, the process entered the STOPPED state. I took core dump of STOPPED process and I saw the kill() system call never returned.

What could be the reason for this behaviour by process?

The process was running when SIGSTP signal received and the signal handler ensured that It does not go into STOPPED state and yet process entered in the STOPPED state,


Santosh.

kakaka 09-21-2012 10:25 PM

greenday, please be aware that some signals cannot be blocked. Sometimes the signal man page in manual section 7 can be very helpful, as can be displayed by executing the command:

Code:

man -S 7 signal
If you are having some specific issue, perhaps for the sake of clarity, you could post some simple source code which illustrates the problem, and ask a very specific question about the code.


All times are GMT -5. The time now is 05:56 AM.