@@ 1,6 1,7 @@
package main
import (
+ "flag"
"fmt"
"os"
"os/signal"
@@ 9,6 10,11 @@ import (
)
func main() {
+ var ignoreTerm bool
+ flag.BoolVar(&ignoreTerm, "ignoreterm", false, "tell signalfun to ignore SIGTERM")
+
+ flag.Parse()
+
fmt.Printf("my PID is %d\n", os.Getpid())
c := make(chan os.Signal, 10)
@@ 32,8 38,13 @@ runloop:
fmt.Println("breaking for SIGKILL")
break runloop
case syscall.SIGTERM:
- fmt.Println("breaking for SIGTERM")
- break runloop
+ if ignoreTerm {
+ fmt.Println("lol ignoring SIGTERM")
+ continue runloop
+ } else {
+ fmt.Println("breaking for SIGTERM")
+ break runloop
+ }
default:
fmt.Printf("continuing despite %+v\n", sig)
continue runloop