Skip to contentSkip to conversation

kill -9?

DISCUSSION Kaleem Khan 3 participants 3 messages Jul 6, 2007

lore
Share & tools
lore
#0 lore raw

Hello Kernel experts,

I'd like to know whether there's a way to take some action (say calling a routine) in
response to 'kill -9' before the process is terminated. I tend to think it's against 'kill -9'
UNIX/Linux philosophy but still I'd like to confirm.

Thank you.

#1 lore raw
Quoted 8 lines · Kaleem Khan

Hello Kernel experts,

I'd like to know whether there's a way to take some action (say calling a routine) in
response to 'kill -9' before the process is terminated. I tend to think it's against 'kill -9'
UNIX/Linux philosophy but still I'd like to confirm.

You can't catch/block SIGKILL (9), but you can catch SIGTERM (15 - what kill sends by default).

A well behaved app should catch SIGTERM and do proper cleanup before shutdown so that when a user does kill <pid_of_app> it shuts down cleanly. kill -9 <pid_of_app> shouldn't normally be needed - it is for emergency termination of the app, which is why you can't catch it.

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
#2 lore raw
Quoted 9 lines · Jesper Juhl
Quoted 8 lines · Kaleem Khan

Hello Kernel experts,

I'd like to know whether there's a way to take some action (say calling a routine) in
response to 'kill -9' before the process is terminated. I tend to think it's against 'kill -9'
UNIX/Linux philosophy but still I'd like to confirm.

Quoted 7 lines

You can't catch/block SIGKILL (9), but you can catch SIGTERM (15 - what kill sends by default).

A well behaved app should catch SIGTERM and do proper cleanup before shutdown so that when a user does kill <pid_of_app> it shuts down cleanly. kill -9 <pid_of_app> shouldn't normally be needed - it is for emergency termination of the app, which is why you can't catch it.

Tell that to Oracle. They believe that they are above any rules and conventions. TERM does not terminate oracle db.

I tried to explain to Oracle DBAs I met how terribly wrong is it. Quite frustrating experience.
--
vda