aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cmd/fshim/ipc/shim/shim.go11
-rw-r--r--internal/app/start.go6
2 files changed, 16 insertions, 1 deletions
diff --git a/cmd/fshim/ipc/shim/shim.go b/cmd/fshim/ipc/shim/shim.go
index a03b6003..db4a9b09 100644
--- a/cmd/fshim/ipc/shim/shim.go
+++ b/cmd/fshim/ipc/shim/shim.go
@@ -5,6 +5,7 @@ import (
"net"
"os"
"os/exec"
+ "os/signal"
"strings"
"sync"
"sync/atomic"
@@ -128,6 +129,16 @@ func (s *Shim) Start() (*time.Time, error) {
}
defer func() { killShim() }()
+ // take alternative exit path on signal
+ sig := make(chan os.Signal, 2)
+ signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
+ go func() {
+ v := <-sig
+ fmsg.Printf("got %s after program start", v)
+ s.killFallback <- nil
+ signal.Ignore(syscall.SIGINT, syscall.SIGTERM)
+ }()
+
accept()
var conn *net.UnixConn
select {
diff --git a/internal/app/start.go b/internal/app/start.go
index 0b90583a..c33d26fb 100644
--- a/internal/app/start.go
+++ b/internal/app/start.go
@@ -179,7 +179,11 @@ func (a *app) Wait() (int, error) {
// alternative exit path when kill was unsuccessful
case err := <-a.shim.WaitFallback():
r = 255
- fmsg.Printf("cannot terminate shim on faulted setup: %v", err)
+ if err != nil {
+ fmsg.Printf("cannot terminate shim on faulted setup: %v", err)
+ } else {
+ fmsg.VPrintln("alternative exit path selected")
+ }
}
}