aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--container/init.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/container/init.go b/container/init.go
index e5ca1718..c5687025 100644
--- a/container/init.go
+++ b/container/init.go
@@ -1,6 +1,7 @@
package container
import (
+ "context"
"errors"
"fmt"
"log"
@@ -64,6 +65,7 @@ type (
setupState struct {
nonrepeatable uintptr
*Params
+ context.Context
message.Msg
}
)
@@ -182,7 +184,9 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
k.fatalf(msg, "cannot make / rslave: %v", optionalErrorUnwrap(err))
}
- state := &setupState{Params: &params.Params, Msg: msg}
+ ctx, cancel := context.WithCancel(context.Background())
+ state := &setupState{Params: &params.Params, Msg: msg, Context: ctx}
+ defer cancel()
/* early is called right before pivot_root into intermediate root;
this step is mostly for gathering information that would otherwise be difficult to obtain
@@ -441,6 +445,9 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
}
if w.wpid == cmd.Process.Pid {
+ // cancel Op context early
+ cancel()
+
// start timeout early
go func() { time.Sleep(params.AdoptWaitDelay); close(timeout) }()