diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-25 13:19:37 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-25 13:19:37 +0900 |
| commit | 31350d74e51d25ee8b180a2d4234ea5d4aa55c2b (patch) | |
| tree | 3efe720bc128f251fbe7ccae71273675c47b8064 /internal/app | |
| parent | 3b82cc55dea66c9c404c73b010203fd6a2c38cdb (diff) | |
shim: kill shim if setup becomes impossible
This prevents a hang when setup faults but the shim keeps waiting on the socket. Setup is automatically aborted when the shim is killed.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/app')
| -rw-r--r-- | internal/app/start.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/app/start.go b/internal/app/start.go index 464d23df..719343fe 100644 --- a/internal/app/start.go +++ b/internal/app/start.go @@ -64,7 +64,14 @@ func (a *app) Start() error { a.cmd.Dir = a.seal.RunDirPath a.abort = make(chan error) - if err := shim.ServeConfig(confSockPath, a.abort, a.seal.sys.UID(), &shim.Payload{ + procReady := make(chan struct{}) + if err := shim.ServeConfig(confSockPath, a.abort, func() { + <-procReady + if err := a.cmd.Process.Signal(os.Interrupt); err != nil { + fmsg.Println("cannot kill shim on faulted setup:", err) + } + fmt.Print("\r") + }, a.seal.sys.UID(), &shim.Payload{ Argv: a.seal.command, Exec: shimExec, Bwrap: a.seal.sys.bwrap, @@ -85,6 +92,7 @@ func (a *app) Start() error { "cannot start process:") } startTime := time.Now().UTC() + close(procReady) // create process state sd := state.State{ |
