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 Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <signal.h>
    int raise( int condition );

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.

Example:
    /*
     * This program waits until a SIGINT signal
     * is received.
     */
    #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("Signal will be auto-raised on iteration "
               "10000 or hit CTRL-C.\n");
        printf("Iteration:      ");
        for( i = 0; i < 100000; ++i )
        {
          printf("\b\b\b\b\b%*d", 5, i);

          if( i == 10000 ) raise(SIGINT);

          if( signal_count > 0 ) break;
        }

        if( i == 100000 ) {
          printf("\nNo signal was raised.\n");
        } else if( i == 10000 ) {
          printf("\nSignal %d was raised by the "
                  "raise() function.\n", signal_number);
        } else {
          printf("\nUser raised the signal.\n",
                  signal_number);
        }
      }

Classification:
    ANSI

Systems:
    All, Netware

See Also:
    signal

See Also: signal

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