diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-23 21:47:06 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-23 21:58:40 +0900 |
| commit | 0166833431633f7acc8b0d35c4451494eff8710a (patch) | |
| tree | 7af41193d37499dc375394d0f78038d8abf5a7f8 /container/init.go | |
| parent | b3da3da525e066c67a14503a3a0d00d5024cc62d (diff) | |
container/dispatcher: start goroutine in dispatcher
This allows instrumentation of calls from goroutine without relying on finalizers.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/init.go')
| -rw-r--r-- | container/init.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/container/init.go b/container/init.go index 6bb5a9e7..44e89c7a 100644 --- a/container/init.go +++ b/container/init.go @@ -178,6 +178,7 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV fmt.Sprintf("cannot prepare op at index %d:", i)) k.beforeExit() k.exit(1) + return } } @@ -218,6 +219,7 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV fmt.Sprintf("cannot apply op at index %d:", i)) k.beforeExit() k.exit(1) + return } } @@ -333,7 +335,7 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV info := make(chan winfo, 1) done := make(chan struct{}) - go func(k syscallDispatcher) { + k.new(func(k syscallDispatcher) { var ( err error wpid = -2 @@ -360,7 +362,7 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV } close(done) - }(k.new()) + }) // handle signals to dump withheld messages sig := make(chan os.Signal, 2) @@ -385,7 +387,9 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV } continue } + k.beforeExit() k.exit(0) + return case w := <-info: if w.wpid == cmd.Process.Pid { @@ -396,9 +400,11 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV case w.wstatus.Exited(): r = w.wstatus.ExitStatus() k.verbosef("initial process exited with code %d", w.wstatus.ExitStatus()) + case w.wstatus.Signaled(): r = 128 + int(w.wstatus.Signal()) k.verbosef("initial process exited with signal %s", w.wstatus.Signal()) + default: r = 255 k.verbosef("initial process exited with status %#x", w.wstatus) @@ -410,11 +416,13 @@ func initEntrypoint(k syscallDispatcher, prepareLogger func(prefix string), setV case <-done: k.beforeExit() k.exit(r) + return case <-timeout: k.printf("timeout exceeded waiting for lingering processes") k.beforeExit() k.exit(r) + return } } } |
