Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - signal http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   signal

   Usage
   #include <signal.h>
   void (*signal(int sig, void (*func)(int)))(int);


   Description
   signal  allows a program to define the how signals from the  operating
   system  are  to  be handled. The sig argument must  be  one  of  these
   constants:

   SIGABRT        Abnormal termination
   SIGFPE         Floating point error
   SIGILL         Illegal instruction
   SIGINT         Interrupt (CTRL+C)
   SIGSEGV        Segment violation
   SIGTERM        Terminate

   The macros below are special values for func:
   SIG_DFL        Handled in the default manner.
   SIG_IGN        Ignored the signal.

   signal sets the response.

   When  a signal happens, first the behavior for the signal is reset  to
   SIG_DFL, then the function for that signal is called and sig is passed
   to it.

   Example
   #include <signal.h>
   #include <stdio.h>

   /* our signal handler function */
   void ctrl_break(int val)
   {
        signal(SIGINT,SIG_IGN);
        printf("Press any key to terminate: ");
        getch();
        exit(0);
   }
   main()
   {
        if(signal(SIGINT,(*ctrl_break)) == SIG_ERR)
        {
             perror("Could not set SIGINT!");
             abort();
        }
        raise(SIGINT);
   }

   Return Value
   signal  returns the previous value of func. A return value of  SIG_ERR
   indicates an error and errno is set to a positive value.


See Also: raise

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson