title: Linux: system() + SIGCHLD handling + multithreading
body: <p>I have a multithreaded application that installs a handler for SIGCHLD that logs and reaps the child processes.<br>
  The problem I see starts when I'm doing a call to <code>system()</code>. <code>system()</code> needs to wait for the child process to end and reaps him itself since it needs the exit code. This is why it calls <code>sigprocmask()</code> to block SIGCHLD. But in my multithreaded application, the SIGCHLD is still called in a different thread and the child is reaped before <code>system()</code> has a chance to do so.</p>
  
  <p>Is this a known problem in POSIX?</p>
  
  <p>One way around this I thought of is to block SIGCHLD in all other threads but this is not really realistic in my case since not all threads are directly created by my code.<br>
  What other options do I have?</p>