#include #include #include void handler(int arg) { switch( arg ) { case SIGHUP: printf("Hello, i am here!\n"); break; case SIGTERM: printf("Hello, time to end!\n"); exit(0); break; } } main() { struct sigaction old, handle; handle.sa_handler = handler; handle.sa_flags = 0; sigemptyset(&handle.sa_mask); sigaddset(&handle.sa_mask, SIGHUP); sigaddset(&handle.sa_mask, SIGTERM); sigaction(SIGHUP, &handle, &old); sigaction(SIGTERM, &handle, &old); printf("my pid is %d\n", getpid()); while(1) pause(); }