Thread: Help with Signal Function

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    115

    Help with Signal Function

    Can anyone describe to me what is happening in the code below. I am having trouble understanding the signal examples online. The exit_handlr function is returning a 0 for success and 1 for process that terminated abnormally. Thanks.

    Code:
    97     signal(SIGHUP,exit_hndlr);
    98     signal(SIGINT,exit_hndlr);
    99     signal(SIGQUIT,exit_hndlr);
    100   signal(SIGTERM,exit_hndlr);

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    This code sets up a signal handler for HUP, INT, QUIT, and TERM -- in other words, all the various signals normally used to terminate a program. Normally, these signals would immediately terminate the program. But with a handler installed, these signals will instead cause the function exit_handlr() to be executed. It's up to exit_handlr() to decide what to do.

    Also, I doubt that the exit_handlr() is returning anything. If it is, it's meaningless, since nothing will ever see that return code.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    115

    Awesome!

    You guys are life savers! Thank you very much for taking time to explain this for me. You are correct about exit_hndlr - it is a void function. Sorry about that.

    -Carl

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Post your games here...
    By Hammer in forum Game Programming
    Replies: 132
    Last Post: 02-28-2013, 09:29 AM
  2. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  3. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM