/*
* the below code is used to register a signal handler.
*/
#include <signal.h>
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
void myhandler(int signum) {
printf("Signal catched!\n");
}
int main(void) {
int ret;
struct sigaction action = {
.sa_handler = myhandler,
};
ret = sigaction(SIGUSR1, & action, NULL);
assert(ret == 0);
while(1);
return 0;
}
No comments:
Post a Comment