Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    int raise( int condition );
    #include <signal.h>

Description:
    The raise function signals the exceptional condition indicated by the
    condition argument.  The possible conditions are defined in the
    <signal.h> header file and are documented with the  signal function.
     The  signal function can be used to specify the action which is to take
    place when such a condition occurs.

Returns:
    The raise function returns zero when the condition is successfully
    raised and a non-zero value otherwise.  There may be no return of
    control following the function call if the action for that condition is
    to terminate the program or to transfer control using the  longjmp
    function.

See Also:
    signal

Example:
    /*
     * This program loops until a SIGINT signal
     * is received or a count is exceeded.
     */
    #include <stdio.h>
    #include <signal.h>

    sig_atomic_t signal_count;
    sig_atomic_t signal_number;

    static void alarm_handler( int signum )
      {
        ++signal_count;
        signal_number = signum;
      }

    void main()
      {
        unsigned long i;

        signal_count = 0;
        signal_number = 0;
        signal( SIGINT, alarm_handler );

        printf( "Program looping. Press Ctrl/C.\n" );
        for( i = 0; i < 3000000; i++ ) {
          if( i > 2000000 ) raise( SIGINT );
          if( signal_count > 0 ) {
            printf( "Signal %d received\n", signal_number );
            break;
          }
        }
      }

Classification:
    ANSI

Systems:
    All

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