diff --git a/daemon/monitor.go b/daemon/monitor.go index 28b41ca116..c307711e20 100644 --- a/daemon/monitor.go +++ b/daemon/monitor.go @@ -156,7 +156,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei daemon.LogContainerEvent(c, "oom") case libcontainerdtypes.EventExit: - if int(ei.Pid) == c.Pid { + if ei.ProcessID == ei.ContainerID { return daemon.handleContainerExit(c, &ei) } diff --git a/libcontainerd/local/local_windows.go b/libcontainerd/local/local_windows.go index da71805dbd..41c50e6e73 100644 --- a/libcontainerd/local/local_windows.go +++ b/libcontainerd/local/local_windows.go @@ -461,7 +461,7 @@ func (ctr *container) Start(_ context.Context, _ string, withStdin bool, attachS } }() t := &task{process: process{ - id: libcontainerdtypes.InitProcessName, + id: ctr.id, ctr: ctr, hcsProcess: newProcess, waitCh: make(chan struct{}), @@ -495,7 +495,7 @@ func (ctr *container) Start(_ context.Context, _ string, withStdin bool, attachS ctr.client.eventQ.Append(ctr.id, func() { ei := libcontainerdtypes.EventInfo{ ContainerID: ctr.id, - ProcessID: libcontainerdtypes.InitProcessName, + ProcessID: t.id, Pid: pid, } ctr.client.logger.WithFields(logrus.Fields{ @@ -793,7 +793,7 @@ func (t *task) Pause(_ context.Context) error { t.ctr.client.eventQ.Append(t.ctr.id, func() { err := t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventPaused, libcontainerdtypes.EventInfo{ ContainerID: t.ctr.id, - ProcessID: libcontainerdtypes.InitProcessName, + ProcessID: t.id, }) t.ctr.client.logger.WithFields(logrus.Fields{ "container": t.ctr.id, @@ -834,7 +834,7 @@ func (t *task) Resume(ctx context.Context) error { t.ctr.client.eventQ.Append(t.ctr.id, func() { err := t.ctr.client.backend.ProcessEvent(t.ctr.id, libcontainerdtypes.EventResumed, libcontainerdtypes.EventInfo{ ContainerID: t.ctr.id, - ProcessID: libcontainerdtypes.InitProcessName, + ProcessID: t.id, }) t.ctr.client.logger.WithFields(logrus.Fields{ "container": t.ctr.id, diff --git a/libcontainerd/remote/client.go b/libcontainerd/remote/client.go index f159a54c16..8bdea8c2c7 100644 --- a/libcontainerd/remote/client.go +++ b/libcontainerd/remote/client.go @@ -213,9 +213,9 @@ func (c *container) Start(ctx context.Context, checkpointDir string, withStdin b t, err = c.c8dCtr.NewTask(ctx, func(id string) (cio.IO, error) { - fifos := newFIFOSet(bundle, libcontainerdtypes.InitProcessName, withStdin, spec.Process.Terminal) + fifos := newFIFOSet(bundle, id, withStdin, spec.Process.Terminal) - rio, err = c.createIO(fifos, libcontainerdtypes.InitProcessName, stdinCloseSync, attachStdio) + rio, err = c.createIO(fifos, stdinCloseSync, attachStdio) return rio, err }, taskOpts..., @@ -278,7 +278,7 @@ func (t *task) Exec(ctx context.Context, processID string, spec *specs.Process, }() p, err = t.Task.Exec(ctx, processID, spec, func(id string) (cio.IO, error) { - rio, err = t.ctr.createIO(fifos, processID, stdinCloseSync, attachStdio) + rio, err = t.ctr.createIO(fifos, stdinCloseSync, attachStdio) return rio, err }) if err != nil { @@ -489,7 +489,7 @@ func (c *container) Task(ctx context.Context) (libcontainerdtypes.Task, error) { // createIO creates the io to be used by a process // This needs to get a pointer to interface as upon closure the process may not have yet been registered -func (c *container) createIO(fifos *cio.FIFOSet, processID string, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) { +func (c *container) createIO(fifos *cio.FIFOSet, stdinCloseSync chan containerd.Process, attachStdio libcontainerdtypes.StdioCallback) (cio.IO, error) { var ( io *cio.DirectIO err error diff --git a/libcontainerd/types/types.go b/libcontainerd/types/types.go index 673b184c03..0b484e23f0 100644 --- a/libcontainerd/types/types.go +++ b/libcontainerd/types/types.go @@ -99,6 +99,3 @@ type Task interface { // StdioCallback is called to connect a container or process stdio. type StdioCallback func(io *cio.DirectIO) (cio.IO, error) - -// InitProcessName is the name given to the first process of a container -const InitProcessName = "init"