@@ -294,7 +294,8 @@ func (c *client) Start(ctx context.Context, id, checkpointDir string, withStdin
294294 t , err = ctr .ctr .NewTask (ctx ,
295295 func (id string ) (cio.IO , error ) {
296296 fifos := newFIFOSet (ctr .bundleDir , InitProcessName , withStdin , spec .Process .Terminal )
297- rio , err = c .createIO (fifos , id , InitProcessName , stdinCloseSync , attachStdio )
297+
298+ rio , err = c .createIO (fifos , id , InitProcessName , stdinCloseSync , attachStdio , spec .Process .Terminal )
298299 return rio , err
299300 },
300301 func (_ context.Context , _ * containerd.Client , info * containerd.TaskInfo ) error {
@@ -365,7 +366,7 @@ func (c *client) Exec(ctx context.Context, containerID, processID string, spec *
365366 }()
366367
367368 p , err = t .Exec (ctx , processID , spec , func (id string ) (cio.IO , error ) {
368- rio , err = c .createIO (fifos , containerID , processID , stdinCloseSync , attachStdio )
369+ rio , err = c .createIO (fifos , containerID , processID , stdinCloseSync , attachStdio , spec . Terminal )
369370 return rio , err
370371 })
371372 if err != nil {
@@ -644,8 +645,16 @@ func (c *client) getProcess(containerID, processID string) (containerd.Process,
644645
645646// createIO creates the io to be used by a process
646647// This needs to get a pointer to interface as upon closure the process may not have yet been registered
647- func (c * client ) createIO (fifos * cio.FIFOSet , containerID , processID string , stdinCloseSync chan struct {}, attachStdio StdioCallback ) (cio.IO , error ) {
648- io , err := cio .NewDirectIO (context .Background (), fifos )
648+ func (c * client ) createIO (fifos * cio.FIFOSet , containerID , processID string , stdinCloseSync chan struct {}, attachStdio StdioCallback , terminal bool ) (cio.IO , error ) {
649+ var (
650+ io * cio.DirectIO
651+ err error
652+ )
653+ if terminal {
654+ io , err = cio .NewDirectIOWithTerminal (context .Background (), fifos )
655+ } else {
656+ io , err = cio .NewDirectIO (context .Background (), fifos )
657+ }
649658 if err != nil {
650659 return nil , err
651660 }
0 commit comments