Updated: April 19, 2023

Generate a signal


#include <signal.h>

int raise( int signo );


The signal that you want to raise. For more information, see signal().

If the signal terminates the process, the cleanup of the terminated process occurs by default at the priority of the thread that sent the signal. As a QNX Neutrino extension, if you OR the SIG_TERMER_NOINHERIT flag (defined in <signal.h>) into signo, the cleanup occurs at the priority of the thread that received the signal.



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The raise() function generates the signal specified by signo. Calling raise() is equivalent to calling:

pthread_kill(pthread_self(), signo);

Use sigaction() or SignalAction() to specify the actions to take when a signal is received.


0 if the specified signo is sent, or nonzero if an error occurs (errno is set).

The raise() function doesn't return if the action for that signal is to terminate the program or to transfer control using the longjmp() function.


Insufficient system resources are available to deliver the signal.
The value of signo isn't a valid signal number.


Wait until a SIGINT signal is received. The signal is automatically raised on iteration 10000, or when you press CtrlC:

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

sig_atomic_t signal_count;
sig_atomic_t signal_number;

void alarm_handler( int signum )
    signal_number = signum;

int main( void )
    unsigned long i;

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

    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 signal #%d.\n",
                signal_number );

    return EXIT_SUCCESS;


ANSI, POSIX 1003.1

Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes