title: What does WEXITSTATUS(status) return?
body: <p>I am trying to understand how <code>WEXITSTATUS(status)</code> works. I have come across a piece of code where the return value of <code>WEXITSTATUS(status)</code> is being added to a variable. </p>
  
  <p>Here is the snippet:</p>
  
  <pre><code>waitpid(-1, &amp;status, 0);
  counter += WEXITSTATUS(status);
  </code></pre>
  
  <p>How can the return value of <code>WEXITSTATUS</code> be calculated?</p>