title: Kill process tree without printing 'Killed' in C
body: <p>I'm trying to kill an entire process tree in C. I am able to do this, however when I run the code, it prints "Killed". I don't want this. Is there any way I can achieve the same result without printing "Killed"?</p>
  
  <p>This is the code I am using:</p>
  
  <pre><code>#define _POSIX_SOURCE
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;signal.h&gt;
  
  #include &lt;unistd.h&gt;
  #include &lt;sys/wait.h&gt;
  
  int main() {
      int pid = fork();
      if (pid == 0) {
          sleep(2);
          printf("child printf\n");
      } else {
          sleep(1);
          kill(-getpid(), SIGKILL);
      }
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>I am compiling this with <code>gcc -std=c99 -Wall test.c</code>. When I run <code>./a.out</code>, this is the output:</p>
  
  <pre><code>Killed
  </code></pre>
  
  <p>If I change the <code>sleep(1)</code> to a <code>sleep(3)</code>, this is the output:</p>
  
  <pre><code>child printf
  Killed
  </code></pre>
  
  <p>In both cases I want the <code>Killed</code> line removed. </p>
  
  <p><b>Note:</b> In the real code, the child process will be <code>execve</code>'d with another. There will be multiple child procceses. Because they can have children themself, doing <code>kill(pid, SIGKILL)</code> won't work.</p>