title: How to kill child of fork?
body: <p>I have the following code which create a child fork. And I want to kill the child before it finish its execution in the parent. how to do it?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  int i;
  
  main (int ac, char **av)
  {
    int pid;
  
    i = 1;
  
    if ((pid = fork()) == 0) {
      /* child */
      while (1) {
        printf ("I m child\n");
        sleep (1);
      }
    }
    else {
      /* Error */
      perror ("fork");
      exit (1);
    }
    sleep (10)
  
     // TODO here: how to add code to kill child??
  
  }
  </code></pre>