title: Sending signal from child to parent
body: <p>Here I want to send SIGINT signal to parent while it is sleeping. I have tried it by writing following the program. In this program, I am not getting why the signal handler for SIGINT from the parent is not executing at all?
  here is the code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;signal.h&gt;
  #include&lt;unistd.h&gt;
  #include&lt;stdlib.h&gt;
  void sig_usr(int signo){
      if(signo == SIGINT)
      printf("Signal caught!");
      return;
  }
  
  int main(void){
      pid_t pid, ppid;
      ppid = getpid();
      printf("ppid = %d\n", ppid);
      if((pid = fork()) == 0){ 
          printf("killing parent...\n");
          kill(ppid, SIGINT);
          printf("After killing parent...\n");
      }
      else{
          sleep(5);
          printf("%d %d ",ppid, pid);
          if(signal(SIGINT,sig_usr) == SIG_ERR)
              printf("Signal processed ");
      }
      return 0;
  }
  </code></pre>
  
  <p>Output:
  The output is printing only this much content. I think parent is not executing at all.</p>
  
  <p><a href="https://i.stack.imgur.com/eNCNw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eNCNw.png" alt="The output is printing only this much content. I think parent is not executing at all."></a></p>