General
cancel
Showing results for 
Search instead for 
Did you mean: 

sigterm from kernel-what are the reasons and how to avoid?

Nagaraj komarsamy
Occasional Contributor

sigterm from kernel-what are the reasons and how to avoid?

Hi all,



Recently, we noticed our processreceived SIGTERM signal from the kernel and exiting. we can not ignore this signal and the processes are so critical that we cannot have these down for even a single minute.

Can you please help me in this,

1) When the kernel generates SIGTERM ?
2) can we ignore this safely ?
3) Is there a way to avoid this ?

Your help is highly appriciated

Thanks in advance

Naga
5 REPLIES
Dennis Handly
Acclaimed Contributor

Re: sigterm from kernel-what are the reasons and how to avoid?

>we noticed our process received SIGTERM signal from the kernel and exiting.

Why do you think the kernel did this?
I've seen the evil kernel do SIGKILL but never SIGTERM. Typically only users cause it.

>we can not ignore this signal

Why not?

>1) When the kernel generates SIGTERM?
>2) can we ignore this safely?
>3) Is there a way to avoid this?

Only when kill(2) or raise(2) is used.
You could ignore it but you would then have users using kill -9.
You would first have to figure out who is killing your process.
Srimalik
Valued Contributor

Re: sigterm from kernel-what are the reasons and how to avoid?

>we can not ignore this signal and the processes are so critical that we cannot have these down for even a single minute.

If this is so important you may want to change you application to ignore SIGTERM or provide custom handler.

You may also run this process with a special userid which is generally not used to login into the system so that nobody(except root) is able to kill this process. Running as root is also a possibility.

But, as Dennis said if somebody has the root privileges and want to kill this process then there is a problem, he will use -9 if TERM fails. :)
abandon all hope, ye who enter here..
Nagaraj komarsamy
Occasional Contributor

Re: sigterm from kernel-what are the reasons and how to avoid?

Hi,

Thanks for your valuable reply.

I am sure SIGTERM not sent manually. It came from some other means(kernel).

Also we handling the signal SIGTERM and the handler will shutdown the process smoothly.

So the handler also working properly.

The problem is how the handler caugt the signal SIGTERM despite the fact that no one have sent it manually.

Who will send the signal?
How to make it not to happen again?

Thanks,
Naga


Dennis Handly
Acclaimed Contributor

Re: sigterm from kernel-what are the reasons and how to avoid?

>I am sure SIGTERM not sent manually. It came from some other means (kernel).

I would look to a person/script. The kernel doesn't do that. It is more evil than SIGTERM, SIGKILL.

>The problem is how the handler caught the signal SIGTERM despite the fact that no one have sent it manually. Who will send the signal?

In your signal handler, you'll need to look at all 3 parms and see if you find the struct that contains the PID that killed you.

>How to make it not to happen again?

You can't until you hunt down your user/script that is killing your process.

You might want to use tusc on your process to see if it is committing suicide.
Venkatesh BL
Honored Contributor

Re: sigterm from kernel-what are the reasons and how to avoid?

I suspect a script. Do you have any cronjob that could potentially do this?