SHARE
TWEET

using trap to catch segfault

a guest Oct 30th, 2012 650 Never
  1. #!/bin/bash
  2. trap 'if [[ $? -eq 139 ]]; then echo "segfault !"; fi' CHLD
  3.  
  4. count=0
  5.  
  6. while :
  7.  do
  8.    sleep 1
  9.    count=$(expr $count + 1)
  10.    echo $count
  11.    ./code >& log
  12.    if [ "$?" -ne 139 ]
  13.         then
  14.                 exit
  15.    fi
  16.  done
RAW Paste Data
Top