diff --git a/runtime/v1/shim/service.go b/runtime/v1/shim/service.go index 679982a7f..df6d8b64e 100644 --- a/runtime/v1/shim/service.go +++ b/runtime/v1/shim/service.go @@ -493,16 +493,24 @@ func (s *Service) processExits() { } } -func (s *Service) checkProcesses(e runc.Exit) { +func (s *Service) allProcesses() []rproc.Process { s.mu.Lock() defer s.mu.Unlock() + res := make([]rproc.Process, 0, len(s.processes)) + for _, p := range s.processes { + res = append(res, p) + } + return res +} + +func (s *Service) checkProcesses(e runc.Exit) { shouldKillAll, err := shouldKillAllOnExit(s.bundle) if err != nil { log.G(s.context).WithError(err).Error("failed to check shouldKillAll") } - for _, p := range s.processes { + for _, p := range s.allProcesses() { if p.Pid() == e.Pid { if shouldKillAll { diff --git a/runtime/v2/runc/service.go b/runtime/v2/runc/service.go index e37fb2976..e3c78d6e7 100644 --- a/runtime/v2/runc/service.go +++ b/runtime/v2/runc/service.go @@ -692,6 +692,8 @@ func shouldKillAllOnExit(bundlePath string) (bool, error) { func (s *service) allProcesses() (o []rproc.Process) { s.mu.Lock() defer s.mu.Unlock() + + o = make([]rproc.Process, 0, len(s.processes)+1) for _, p := range s.processes { o = append(o, p) } diff --git a/runtime/v2/shim/shim_unix.go b/runtime/v2/shim/shim_unix.go index 6f1ef6e28..937aaaf0d 100644 --- a/runtime/v2/shim/shim_unix.go +++ b/runtime/v2/shim/shim_unix.go @@ -87,7 +87,7 @@ func handleSignals(logger *logrus.Entry, signals chan os.Signal) error { } func openLog(ctx context.Context, _ string) (io.Writer, error) { - return fifo.OpenFifo(context.Background(), "log", unix.O_WRONLY, 0700) + return fifo.OpenFifo(ctx, "log", unix.O_WRONLY, 0700) } func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error {