cmd/fshim/ipc: install signal handler on shim start
test / test (push) Successful in 20s
Details
test / test (push) Successful in 20s
Details
Getting killed at this point will result in inconsistent state. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
This commit is contained in:
parent
c026a4b5dc
commit
ae2628e57a
|
@ -5,6 +5,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -128,6 +129,16 @@ func (s *Shim) Start() (*time.Time, error) {
|
||||||
}
|
}
|
||||||
defer func() { killShim() }()
|
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()
|
accept()
|
||||||
var conn *net.UnixConn
|
var conn *net.UnixConn
|
||||||
select {
|
select {
|
||||||
|
|
|
@ -179,7 +179,11 @@ func (a *app) Wait() (int, error) {
|
||||||
// alternative exit path when kill was unsuccessful
|
// alternative exit path when kill was unsuccessful
|
||||||
case err := <-a.shim.WaitFallback():
|
case err := <-a.shim.WaitFallback():
|
||||||
r = 255
|
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue