title: Determining if a python subprocess segmentation faults
body: <p>I am writing a program that grades student programs, and as I am sure you can imagine, they sometimes segmentation fault.  The problem I am having is that when the student programs segmentation fault, there is no indication that is what happened.</p>
  <pre><code>proc = subprocess.Popen(student_command, 
                          stdout=subprocess.PIPE, 
                          stderr=subprocess.PIPE)
  self.stdout, self.stderr = proc.communicate()
  self.returncode = proc.returncode
  </code></pre>
  <p>I pick up the <code>stderr</code>, <code>stdout</code>, and the return code from the <code>subprocess</code>, but if the program segmentation faults, <code>stderr</code> is empty, <code>stdout</code> is empty, and the return code is -11. Now I could look for the -11 exit code and assume that if that is the return code there was a segmentation fault, but there is also nothing to prevent a student's code from having -11 as a return code just because the student felt like returning -11.</p>
  <p>How do you tell if a subprocess segmentation faults, as opposed to just feeling like returning -11?  I don't really care all that much about what is in stderr and stdout, and to that end have seen a number of posts including <a href="https://stackoverflow.com/questions/10577055/python-subprocess-module-does-not-return-stdout-on-segfault">this</a> that deal with picking up the output, but I don't care all that much about the output, although it would be nice to get the &quot;Segmentation Fault&quot; string out of stderr, but what I really need is a way to definitively tell what happened to the subprocess.</p>