Advertisement
JPeterson

deadlock.test.sh

Oct 11th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.82 KB | None | 0 0
  1. #!/bin/bash
  2. # Cygwin spawn wait deadlock test.
  3. # (C) John Peterson. License GNU GPL 3.
  4. function logb() { printf "\033[1;30m$1%s\033[0m"; }
  5. function logc() { printf "\033[0;36m$1%s\033[0m"; }
  6. function iscygwin() {
  7.     if [ -n "`objdump -p ./readm.exe|grep cygwin1.dll`" ]; then echo true; else echo false; fi
  8. }
  9. if $(iscygwin); then printf "readm must be non-cygwin process. please build with mingw.) \n"; exit 0; fi
  10. function time_s() {
  11.     echo -n `date +%s`
  12. }
  13. logb "Running pgrep repeatedly. If the counter stops it\'s deadlocked. (Terminate pgrep with \'taskkill /f /im pgrep.exe\' to end the loop.)\n"
  14. { n=0; t=$(time_s); while :; do
  15.     logc "`printf "\r\033[Kpgrep bash %d" $i`"
  16.     pgrep bash>/dev/null
  17.     if [ $(($(time_s)-2)) -gt $t ]; then logb "`printf "\nexit from deadlock\n"`"; break; fi
  18.     t=$(time_s)
  19.     ((i++))
  20. done; }|./readm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement