summaryrefslogtreecommitdiff
path: root/exit.go
diff options
context:
space:
mode:
Diffstat (limited to 'exit.go')
-rw-r--r--exit.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/exit.go b/exit.go
index 107230c..4bffade 100644
--- a/exit.go
+++ b/exit.go
@@ -92,3 +92,27 @@ func ExitWatchdog() {
}
}
}
+
+func Defer(dur time.Duration, f func()) {
+ dog := time.NewTicker(5 * time.Second)
+ defer dog.Stop()
+ dogchan := make(chan bool)
+ /*
+ // this example would exit/destroy the ticker in 10 seconds
+ go func() {
+ time.Sleep(10 * time.Second)
+ done <- true
+ }()
+ */
+ for {
+ select {
+ case <-dogchan:
+ fmt.Println("Done!")
+ return
+ case t := <-dog.C:
+ _ = t
+ fmt.Println("argv.Exit() watchdog: stalled in", me.pb.AppInfo.APPNAME+".Exit()")
+ // h.Scan()
+ }
+ }
+}