Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

using trap to catch segfault

By: a guest on Oct 30th, 2012  |  syntax: Bash  |  size: 0.24 KB  |  views: 219  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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