Permalink
Browse files

Shut down watcher cleanly when exiting

  • Loading branch information...
mrnugget committed Mar 28, 2013
1 parent da0dad4 commit f8e3f600c593385a8d7b462b1f9cd3e252595a13
Showing with 8 additions and 0 deletions.
  1. +8 −0 watchgopher.go
View
@@ -33,6 +33,14 @@ func main() {
os.Exit(1)
}
+ defer func() {
+ err = watcher.Stop()
+ if err != nil {
+ fmt.Println("Error: Did not shut down cleanly")
+ os.Exit(1)
+ }
+ }()
+
// @TODO: Manage the events, check if a rule applies (file is in path),
// then run script with arguments
for ev := range watcher.Events {

0 comments on commit f8e3f60

Please sign in to comment.