aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/fshim/ipc
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-11-18 13:33:46 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-11-18 13:33:46 +0900
commitae2628e57a25e86568fe00281f07cecfa103cde4 (patch)
treeaeaec7c1fcbf67bf315474d9459fca49116dc03f /cmd/fshim/ipc
parentc026a4b5dc6367caa3e09c0320fa602f6e433ed6 (diff)
cmd/fshim/ipc: install signal handler on shim start
Getting killed at this point will result in inconsistent state. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'cmd/fshim/ipc')
-rw-r--r--cmd/fshim/ipc/shim/shim.go11
1 files changed, 11 insertions, 0 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 {