title: How to avoid zombie processes after executing them in background
body: <p>we are programming a bash like shell in C but we have problems with the background processes.
  The thing is that the father waits for the children process when there is no &amp;, we have made a signal_handler for SIGCHLD which have a wait inside.</p>
  
  <p>The main problem that we want to avoid is: the signal_handler executes always (with background  and foreground processes), so if the signal_handler catches the SIGCHLD before the father process, the father's wait has not children to wait for, so it returns a error.</p>
  
  <p>We depend on who of them executes before, and we want that if there isn't &amp; the signal_handler wait doesn't collect the children before the father does.</p>
  
  <p>Any help could be of paramount importance. Thanks a lot in advance.</p>