title: kill zombie - C - Linux
body: <p>I have two questions because I'm new with C language (for Linux) and I don't know if these piece of codes can be correctly:</p>
  
  <pre><code>void sigchld_h (int signum);
  
  int main(int argc, char *argv[]){
  
  ...;
  
      signal(SIGCHLD,sigchld_h);
  
  ...;
  
  }
  
  void sigchld_h (int signum){
  
      pid_t pid;
  
      int status;
  
      while ( (pid = waitpid(-1,&amp;status,WNOHANG)) &gt; 0)
  
          printf("Child %d terminated\n",pid);
  }
  </code></pre>
  
  <p>Capture "ctrl-C" and close socket and kill child processes:</p>
  
  <pre><code>void termina(int sig);
  
  int main(int argc, char *argv[]){
  
  ...;
  
      signal(SIGINT,termina);
  
  ...;
  
  }
  
  void termina(int sig){
  
  Close(s);
  
  Close(socket_connesso);
  
  return;
  }
  </code></pre>
  
  <p>Thank you very much to all people that will analyze my code. Thanks</p>