diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-07-29 02:38:17 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-07-29 02:38:17 +0900 |
| commit | 940ee00ffee9208a244a99ff085a981c1af1d7c4 (patch) | |
| tree | b57465c48ccfb0eb594c84221aaf7bfd4aa6f444 | |
| parent | b43d10468039a07ada412dcab83e8e074ab9ef46 (diff) | |
container/init: configurable lingering process wait delay
Signed-off-by: Ophestra <cat@gensokyo.uk>
| -rw-r--r-- | container/container.go | 10 | ||||
| -rw-r--r-- | container/init.go | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/container/container.go b/container/container.go index 09360df5..7f2d9b97 100644 --- a/container/container.go +++ b/container/container.go @@ -68,6 +68,8 @@ type ( Args []string // Deliver SIGINT to the initial process on context cancellation. ForwardCancel bool + // time to wait for linger processes after death of initial process + AdoptWaitDelay time.Duration // Mapped Uid in user namespace. Uid int @@ -128,6 +130,14 @@ func (p *Container) Start() error { p.SeccompPresets |= seccomp.PresetDenyTTY } + if p.AdoptWaitDelay == 0 { + p.AdoptWaitDelay = 5 * time.Second + } + // to allow disabling this behaviour + if p.AdoptWaitDelay < 0 { + p.AdoptWaitDelay = 0 + } + p.cmd = exec.CommandContext(ctx, MustExecutable()) p.cmd.Args = []string{initName} p.cmd.Stdin, p.cmd.Stdout, p.cmd.Stderr = p.Stdin, p.Stdout, p.Stderr diff --git a/container/init.go b/container/init.go index 9c4f810a..d4fce6e6 100644 --- a/container/init.go +++ b/container/init.go @@ -17,9 +17,6 @@ import ( ) const ( - // time to wait for linger processes after death of initial process - residualProcessTimeout = 5 * time.Second - /* intermediate tmpfs mount point this path might seem like a weird choice, however there are many good reasons to use it: @@ -358,7 +355,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) { msg.Verbosef("initial process exited with status %#x", w.wstatus) } - go func() { time.Sleep(residualProcessTimeout); close(timeout) }() + go func() { time.Sleep(params.AdoptWaitDelay); close(timeout) }() } case <-done: msg.BeforeExit() |
