Merge pull request #38001 from fuweid/bugfix_issue_37870
bugfix: wait for stdin creation before CloseIO
This commit is contained in:
commit
46368fd179
1 changed files with 10 additions and 1 deletions
|
@ -328,6 +328,13 @@ func (c *client) Start(ctx context.Context, id, checkpointDir string, withStdin
|
|||
return int(t.Pid()), nil
|
||||
}
|
||||
|
||||
// Exec creates exec process.
|
||||
//
|
||||
// The containerd client calls Exec to register the exec config in the shim side.
|
||||
// When the client calls Start, the shim will create stdin fifo if needs. But
|
||||
// for the container main process, the stdin fifo will be created in Create not
|
||||
// the Start call. stdinCloseSync channel should be closed after Start exec
|
||||
// process.
|
||||
func (c *client) Exec(ctx context.Context, containerID, processID string, spec *specs.Process, withStdin bool, attachStdio StdioCallback) (int, error) {
|
||||
ctr := c.getContainer(containerID)
|
||||
if ctr == nil {
|
||||
|
@ -372,7 +379,9 @@ func (c *client) Exec(ctx context.Context, containerID, processID string, spec *
|
|||
ctr.addProcess(processID, p)
|
||||
|
||||
// Signal c.createIO that it can call CloseIO
|
||||
close(stdinCloseSync)
|
||||
//
|
||||
// the stdin of exec process will be created after p.Start in containerd
|
||||
defer close(stdinCloseSync)
|
||||
|
||||
if err = p.Start(ctx); err != nil {
|
||||
p.Delete(context.Background())
|
||||
|
|
Loading…
Add table
Reference in a new issue