|
@@ -45,7 +45,7 @@ func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error
|
|
// AddProcess is the handler for adding a process to an already running
|
|
// AddProcess is the handler for adding a process to an already running
|
|
// container. It's called through docker exec. It returns the system pid of the
|
|
// container. It's called through docker exec. It returns the system pid of the
|
|
// exec'd process.
|
|
// exec'd process.
|
|
-func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process, attachStdio StdioCallback) (int, error) {
|
|
|
|
|
|
+func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process, attachStdio StdioCallback) (pid int, err error) {
|
|
clnt.lock(containerID)
|
|
clnt.lock(containerID)
|
|
defer clnt.unlock(containerID)
|
|
defer clnt.unlock(containerID)
|
|
container, err := clnt.getContainer(containerID)
|
|
container, err := clnt.getContainer(containerID)
|
|
@@ -101,7 +101,14 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly
|
|
Rlimits: convertRlimits(sp.Rlimits),
|
|
Rlimits: convertRlimits(sp.Rlimits),
|
|
}
|
|
}
|
|
|
|
|
|
- iopipe, err := p.openFifos(sp.Terminal)
|
|
|
|
|
|
+ fifoCtx, cancel := context.WithCancel(context.Background())
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+ cancel()
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ iopipe, err := p.openFifos(fifoCtx, sp.Terminal)
|
|
if err != nil {
|
|
if err != nil {
|
|
return -1, err
|
|
return -1, err
|
|
}
|
|
}
|
|
@@ -335,7 +342,14 @@ func (clnt *client) restore(cont *containerd.Container, lastEvent *containerd.Ev
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- iopipe, err := container.openFifos(terminal)
|
|
|
|
|
|
+ fifoCtx, cancel := context.WithCancel(context.Background())
|
|
|
|
+ defer func() {
|
|
|
|
+ if err != nil {
|
|
|
|
+ cancel()
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ iopipe, err := container.openFifos(fifoCtx, terminal)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|