C signal.h Library Function

C <signal.h> library function: The signal.h library function defines a variable type sig_atomic_t, two function calls, and several macros to handle different signals reported during a program’s execution.

C <signal.h> Library Function

Library Variables

sig_atomic_t: It is of int type and is used as a variable in a signal handler. And this is an integral type of an object that can be accessed as an atomic entity, even in the presence of asynchronous signals.

Library Macros

Macro Description
SIG_DFL Default signal handler
SIG_ERR Represents a signal error
SIG_IGN Signal ignore

Library Functions

  • void (*signal(int sig, void (*func)(int)))(int) : This function sets a function to handle signal i.e. a signal handler.
  • int raise(int sig): This function causes signal sig to be generated. And the argument is compatible with the SIG macros.