How to check Ubuntu program coredump in either bash or python?
<p>I have a binary foo, and i will give a file input to foo which may potentially trigger coredump in Ubuntu. I write a loop to do so and I change the file content in every iteration. But I would like to terminate the loop whenever a coredump appears. Here is the bash code:</p>

<pre><code>while true
do
  change_file file_s &gt; file_new
  ./foo file_new
  # need to check coredump to terminate the loop
done
</code></pre>

<p>I can change the script to python if it is easier to do that in python.</p>

<p>If the return code is greater than 127, then the program exited due to a signal. Core dumps only happen as the result of this sort of exit.</p>

<pre><code>./foo file_new
if (($? &gt; 127)); then
    echo foo crashed
    break
fi
</code></pre>

python bash ubuntu coredump