aboutsummaryrefslogtreecommitdiffhomepage
path: root/container
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-12-09 08:12:22 +0900
committerOphestra <cat@gensokyo.uk>2025-12-09 08:12:22 +0900
commita3fd05765ebe293aaa60045b158b62e50db24803 (patch)
treebccc14f19a0dc5a0ddda767b536795099887c154 /container
parentc538df7daa21ce6c878b4ead7f0e06c4a0db8147 (diff)
container: load initial process started before syscall
This avoids a race between returning from syscall and checking the state. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container')
-rw-r--r--container/init.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/container/init.go b/container/init.go
index 04c643d9..53fc5475 100644
--- a/container/init.go
+++ b/container/init.go
@@ -380,6 +380,9 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
err error
wpid = -2
wstatus WaitStatus
+
+ // whether initial process has started
+ started bool
)
// keep going until no child process is left
@@ -406,6 +409,10 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
}
}
+ if !started {
+ started = initialProcessStarted.Load()
+ }
+
err = EINTR
for errors.Is(err, EINTR) {
wpid, err = k.wait4(-1, &wstatus, 0, nil)
@@ -414,7 +421,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
if !errors.Is(err, ECHILD) {
k.printf(msg, "unexpected wait4 response: %v", err)
- } else if !initialProcessStarted.Load() {
+ } else if !started {
// initial process has not yet been reached and all daemons
// terminated or none were started in the first place
time.Sleep(500 * time.Microsecond)