aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/init.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-10 20:35:59 +0900
committerOphestra <cat@gensokyo.uk>2025-11-10 20:35:59 +0900
commit2f74adc8bdeda2499be0a8b2711f68c342695bf2 (patch)
tree4a4b4f0899e0d56b3ca5c228298f978bc1f984bb /container/init.go
parentd7e0104ae4da25f455630aae044adf165201c9b5 (diff)
container/init: close initial process files on termination
This closes them during the adopt wait delay. This also keeps them alive. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/init.go')
-rw-r--r--container/init.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/container/init.go b/container/init.go
index fd513efd..592ef302 100644
--- a/container/init.go
+++ b/container/init.go
@@ -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: