SIG_ERR - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# SIG_ERR

From cppreference.com
< c‎ | program

Defined in header `<signal.h>` |  |
#define SIG_ERR /* implementation defined */ |  |

A value of type `void (*)(int)`. When returned by signal, indicates that an error has occurred.

### [edit] Example

Run this code

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

    void signal_handler(int signal)
    {
        printf("Received signal %d\n", signal);
    }

    int main(void)
    {
        /* Install a signal handler. */
        if (signal(SIGTERM, signal_handler) == SIG_ERR)
        {
            printf("Error while installing a signal handler.\n");
            exit(EXIT_FAILURE);
        }

        printf("Sending signal %d\n", SIGTERM);
        if (raise(SIGTERM) != 0)
        {
            printf("Error while raising the SIGTERM signal.\n");
            exit(EXIT_FAILURE);
        }

        printf("Exit main()\n");
        return EXIT_SUCCESS;
    }

Output:

    Sending signal 15
    Received signal 15
    Exit main()

### [edit] See also

signal | sets a signal handler for particular signal (function) [edit]
C++ documentation for SIG_ERR

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/program/SIG_ERR&oldid=69698"