container/init: close initial process files on termination
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m29s
Test / Sandbox (race detector) (push) Successful in 4m28s
Test / Hakurei (push) Successful in 4m34s
Test / Hpkg (push) Successful in 4m42s
Test / Hakurei (race detector) (push) Successful in 6m9s
Test / Flake checks (push) Successful in 1m26s

This closes them during the adopt wait delay. This also keeps them alive.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-11-10 20:35:59 +09:00
parent d7e0104ae4
commit 2f74adc8bd
6 changed files with 27 additions and 5 deletions

View File

@@ -427,6 +427,16 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
}
if w.wpid == cmd.Process.Pid {
// start timeout early
go func() { time.Sleep(params.AdoptWaitDelay); close(timeout) }()
// close initial process files; this also keeps them alive
for _, f := range extraFiles {
if err := f.Close(); err != nil {
msg.Verbose(err.Error())
}
}
switch {
case w.wstatus.Exited():
r = w.wstatus.ExitStatus()
@@ -440,8 +450,6 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
r = 255
msg.Verbosef("initial process exited with status %#x", w.wstatus)
}
go func() { time.Sleep(params.AdoptWaitDelay); close(timeout) }()
}
case <-timeout: