title: Return code when OOM killer kills a process
body: <p>I am running a multiprogrammed workload (based on SPEC CPU2006 benchmarks) on a POWER7 system using SUSE SLES 11.</p>
  <p>Sometimes, each application in the workload consumes a significant amount of memory and the total memory footprint exceeds the available memory installed in the system (32 GB).</p>
  <p>I disabled the swap since otherwise the measurements could be heavily affected for the processes using the swap. I know that by doing that the kernel, through the OOM killer, may kill some of the processes. That is totally fine. The problem is that I would expect that a thread killed by the kernel exited with an error condition (e.g., the process was terminated by a signal).</p>
  <p>I have a framework that launches all the processes and then waits for them using</p>
  <pre><code>waitpid(pid, &amp;status, 0);
  </code></pre>
  <p>Even if a thread is killed by the OOM killer (I know that since I get a message in the screen and in /var/log/messages), the call</p>
  <pre><code>WIFEXITED(status);
  </code></pre>
  <p>returns one, and the call</p>
  <pre><code>WEXITSTATUS(status);
  </code></pre>
  <p>returns zero. Therefore, I am not able to distinguish when a process finishes correctly and when it is killed by the OOM killer.</p>
  <p>Am I doing anything wrong? Do you know any way to detect when a process has been killed by the OOM killer.</p>
  <p>I found <a href="https://stackoverflow.com/questions/742413/return-code-when-os-kills-your-process">this post</a> asking pretty much the same question. However, since it is an old post and answers were not satisfactory, I decided to post a new question.</p>