signal in c code example

Example 1: signal function c

/**
 * @param sig - the signal number
 * @param func - pointer to the handler function
 */
void (*signal(int sig, void (*func)(int)))(int);

Example 2: signal handlers in c

kill -l for all the signals

use signal function to register signal handlers
man signal

Example 3: c signals

#define SIGHUP  1   /* Hangup the process */ 
#define SIGINT  2   /* Interrupt the process */ 
#define SIGQUIT 3   /* Quit the process */ 
#define SIGILL  4   /* Illegal instruction. */ 
#define SIGTRAP 5   /* Trace trap. */ 
#define SIGABRT 6   /* Abort. */

Tags:

C Example