0100-signal.sh - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
       0100-signal.sh (475B)
       ---
            1 #!/bin/sh
            2 
            3 cleanup()
            4 {
            5         rm -f test.txt
            6         kill -KILL $pid 2>/dev/null
            7         if test $1 -ne 0
            8         then
            9                 kill -KILL $$
           10         fi
           11 }
           12 
           13 rm -f file.txt
           14 trap 'cleanup 0' EXIT
           15 trap 'cleanup 1' INT TERM HUP
           16 
           17 scc make -f - test.txt <<'EOF' &
           18 .PRECIOUS: test.txt
           19 
           20 test.txt:
           21         @touch $@
           22         @while : ; do sleep 1 ; done
           23 EOF
           24 pid=$!
           25 
           26 sleep 10 && echo timeout >&2 && kill $$ 2>/dev/null &
           27 timer=$!
           28 
           29 while :
           30 do
           31         if test -f test.txt
           32         then
           33                 kill $pid
           34                 wait $pid
           35                 kill $timer
           36                 break
           37         fi
           38 done
           39 
           40 test -f test.txt