This is the process group : (ps -ejH)

 xxxx  xxxx  xxxx ?        00:00:00   sshd
 yyyy  yyyy  yyyy ?        00:00:00     sshd
 8713  8713  8713 pts/0    00:00:00       bash

 1234  1234  1234 ?        00:00:00   Process 1
 5678  1234  1234 ?        00:00:00     openvt
 3789  3789  3789 tty4     00:00:00       Python process

The states of the processes are :

Process1 : Ss [Interruptible sleep and session leader]

openvt : S [Interruptible sleep]

python process: Ss+ [Interruptible Sleep and session leader and Foreground running process]

I'm working in terminal /dev/pts0 [8713] bash.

When I send kill 1234, it kills process1 alone but not its child process. so,I have written a function in Process1 that kills its sub processes before exiting itself.

When I call this function using trap as:

trap function_name SIGTERM

and sending kill 1234 or kill -15 1234 or kill -s TERM 1234 , the trap function doesn't capture the signal to call the function that I have written.

again, when I remove the trap command from process1 and calling kill 1234, it kills the procces1.

I think the execution control is on openvt and not on process1 when both are running in background and because of this kill command is not received by the process1.

Now how to make the process1 to receive the kill command ?

PS: the openvt here opens a new virtual terminal to run python process. the command used to do this is: openvt -f -s -c 4 -w python_process . The -w waits for command to complete.

Note: From linux-journal If a process receives a signal when it is in an interruptible sleep state, for example, waiting for terminal I/O, the kernel will awaken the process to handle the signal. If a process receives a signal when it is in uninterruptible sleep, such as waiting for disk I/O, the kernel defers the signal until the event completes.

The Kill signal that I sent to process1 is in interruptible sleep state (S), but the kernel defers the signal .. Why ?

There is a post based on this, but it is not solved.

update 1: When I kill all the child processes of parent process using the command pkill -TERM -p pid and when I called kill pid, the signal is catched by the trap command.

  • Its specified in the man page that the default signal for kill is SIGTERM. so I presume kill 1234 sends SIGTERM signal and not SIGINTR – Langdon Mar 13 '15 at 16:28
  • D'oh, so it does. Sigh, I'm old. – Kenster Mar 13 '15 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.