#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
void signal_handler(int signo){
printf("caught SIGINT\n");
psignal(signo,"Received signal");
}
int main(void) {
if (signal(SIGINT, sigintl_handler) == SIG_ERR ){
fprintf(stderr,"cannot handle sig\n");
exit(EXIT_FAILURE);
}
for (; ;) pause();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
void myhandler (int sigtype){
printf("got signal %d\n",sigtype);
}
void main(void){
struct sigaction act;
int n;
int p[2];
char buf(1000);
pipe(p);
act.sa_handler = myhandler;
sigemptyset(&act.sa_mask);
act.sa_flag = 0;
sigaction(SIGINT, &action, NULL);
while (1){
n = read(p[0], buf, 1000);
}
}