Thread: Processing kill signal, possible?

  1. #1
    Registered User
    Join Date
    Nov 2006

    Processing kill signal, possible?

    Hello there,
    I've been wondering, if it's possible to somehow process kill signal? What I mean is, if I call signal(SIGKILL, funptr), will it ever execute? I tried that with printing some output, but it didn't work... then I found out that printf might not work properly in handler function.
    I'm asking since a friend told me it's possible to do that, identyfiy kill signal and do some stuff before it terminates process. So basicly process will get terminated in the end, but with something being done before. And myself, I found that SIGKILL/SIGSTOP may not be ignored/processed.
    Background story is, I'm writing some simple wannabe IRC server/client (based on message queues, so not that much I :P), and when client's user decides to kill client instead of typing /logout to quit properly, I'd like to notify server about that, by somehow sending /logout command to server before client gets terminated.

    Thanks in advance,

  2. #2
    Join Date
    Nov 2003
    The client's user would likely enter ctrl/c which usually defaults to SIGINT which you can trap.
    If you want to be sure, set ctrl/c to SIGINT and return the setting on exit. See man termios. Anyway, if the user enters a kill -9 command, then the chances are the client is hosed anyway.

    You do know it is possible to detect a "hangup" with some types of IPC?

  3. #3
    Registered User
    Join Date
    Nov 2006
    Ah, thanks! Thought kill is being send by ctrl / c.
    And what do you mean with "hangup" detecting, like, checking if there's any process listening..?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Libraries for Audio Signal Processing?
    By GOBLIN-85 in forum C++ Programming
    Replies: 4
    Last Post: 06-15-2009, 01:12 AM
  2. Rotation and signal processing?
    By h3ro in forum Tech Board
    Replies: 3
    Last Post: 07-09-2008, 08:42 PM
  3. Kill Signal Number? - Help !
    By brett in forum C Programming
    Replies: 5
    Last Post: 06-20-2007, 03:39 AM
  4. using a signal handler to kill processes
    By dinjas in forum C Programming
    Replies: 2
    Last Post: 03-16-2005, 12:58 PM