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++ 3.0r4 - <b>signal</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
signal

Usage

   #include <signal.h>
   void (*signal(int sig, void (*handler)(int)))(int)

   ANSI

Description

   signal allows a program to define 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

   SIGSEGV          Segment violation

   SIGTERM          Terminate (CTRL+C)


   The macros below are special values for func:


   SIG_DFL          Handled in the default manner.

   SIG_IGN          Ignored the signal.


   signal sets the response. func should be declared with C linkage.


   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>
   #include <stdlib.h>

   /* our signal handler function */

   void cdecl ctrl_break(int val)
   {
       signal(SIGTERM,SIG_IGN);
       printf("Press any key to terminate: ");
       getch();
       exit(EXIT_SUCCESS);
   }


   int main()
   {
       if(signal(SIGTERM,ctrl_break) == SIG_ERR)
           {
               perror("Could not set SIGTERM!");
               abort();
           }
       raise(SIGTERM);
       return EXIT_SUCCESS;
   }

Return Value

   signal returns the previous value of func. A return value of SIG_ERR
   indicates an error and errno is set.

See Also

   raise




See Also: raise

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