Permalink
Browse files

handle ctrl-c

  • Loading branch information...
1 parent e34108a commit deafc3a0bfc888d1c3cf0c5865483a02b03acb6d @mmcgrana committed Oct 11, 2012
Showing with 16 additions and 7 deletions.
  1. +4 −4 examples/goroutines/goroutines.go
  2. +12 −3 tools/build-loop
View
8 examples/goroutines/goroutines.go
@@ -27,10 +27,10 @@ func main() {
fmt.Println("going")
}()
- // Since our two goroutines are running asynchrously
- // in separate goroutines now, execution immediatly
- // falls through to here. This `Scanln` code requires
- // that we press a key before the program exits.
+ // Our two goroutines are running asynchrously in
+ // separate goroutines now, so execution falls through
+ // to here. This `Scanln` code requires we press a key
+ // before the program exits.
var input string
fmt.Scanln(&input)
fmt.Println("done")
View
15 tools/build-loop
@@ -1,12 +1,21 @@
#!/bin/bash
+TRAPPING=0
+trap "{ echo finishing; TRAPPING=1; }" SIGINT
+
while :
do
tools/build
- if [ "$?" == "0" ]; then
+ RET=$?
+ if [ $RET -eq 0 ]; then
echo "success"
else
- echo "error"
+ echo "error: $RET"
+ fi
+ if [ $TRAPPING -eq 0 ]; then
+ sleep 1
+ else
+ echo "done"
+ exit 0
fi
- sleep 1
done

0 comments on commit deafc3a

Please sign in to comment.