#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

void fun(int signo)
{
   printf("process capture SIGINT\n");
   signal(SIGINT,SIG_DFL);
}

main()
{
   int pid;
   if((pid=fork())==-1)
   {
	perror("fork");
	exit(1);
   }
   else if(pid==0)
   {
	signal(SIGINT,fun);
	printf("child %d waiting for parent %d sent signal\n",getpid(),getppid());
	pause();
	while(1)
	{
	   sleep(1);
	   printf("child\n");
	}
   }
   else
   {
	sleep(1);
	printf("parent %d will sent a signal to child %d\n",getpid(),pid);
	kill(pid,SIGINT);
        while(1)
	{
	   sleep(1);
	   printf("parent\n");
	}
	wait(NULL);
   }
}
