ctr: exec handle pty resize after Start
Handle initial pty resize after the exec process has started and the pty is available, consistent with the behavior of ctr run. Signed-off-by: Samuel Karp <me@samuelkarp.com>
This commit is contained in:
parent
b9378b4529
commit
5dec27b6f1
@ -117,30 +117,31 @@ var execCommand = cli.Command{
|
|||||||
con console.Console
|
con console.Console
|
||||||
)
|
)
|
||||||
|
|
||||||
ioOpts := []cio.Opt{cio.WithFIFODir(context.String("fifo-dir"))}
|
fifoDir := context.String("fifo-dir")
|
||||||
if tty {
|
logURI := context.String("log-uri")
|
||||||
|
ioOpts := []cio.Opt{cio.WithFIFODir(fifoDir)}
|
||||||
|
switch {
|
||||||
|
case tty && logURI != "":
|
||||||
|
return errors.New("can't use log-uri with tty")
|
||||||
|
case logURI != "" && fifoDir != "":
|
||||||
|
return errors.New("can't use log-uri with fifo-dir")
|
||||||
|
|
||||||
|
case tty:
|
||||||
con = console.Current()
|
con = console.Current()
|
||||||
defer con.Reset()
|
defer con.Reset()
|
||||||
if err := con.SetRaw(); err != nil {
|
if err := con.SetRaw(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStreams(con, con, nil), cio.WithTerminal}, ioOpts...)...)
|
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStreams(con, con, nil), cio.WithTerminal}, ioOpts...)...)
|
||||||
} else if logURI := context.String("log-uri"); logURI != "" {
|
|
||||||
|
case logURI != "":
|
||||||
uri, err := url.Parse(logURI)
|
uri, err := url.Parse(logURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if dir := context.String("fifo-dir"); dir != "" {
|
|
||||||
return errors.New("can't use log-uri with fifo-dir")
|
|
||||||
}
|
|
||||||
|
|
||||||
if tty {
|
|
||||||
return errors.New("can't use log-uri with tty")
|
|
||||||
}
|
|
||||||
|
|
||||||
ioCreator = cio.LogURI(uri)
|
ioCreator = cio.LogURI(uri)
|
||||||
} else {
|
|
||||||
|
default:
|
||||||
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStreams(stdinC, os.Stdout, os.Stderr)}, ioOpts...)...)
|
ioCreator = cio.NewCreator(append([]cio.Opt{cio.WithStreams(stdinC, os.Stdout, os.Stderr)}, ioOpts...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,23 +162,20 @@ var execCommand = cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !detach {
|
|
||||||
if tty {
|
|
||||||
if err := HandleConsoleResize(ctx, process, con); err != nil {
|
|
||||||
logrus.WithError(err).Error("console resize")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sigc := commands.ForwardAllSignals(ctx, process)
|
|
||||||
defer commands.StopCatch(sigc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := process.Start(ctx); err != nil {
|
if err := process.Start(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if detach {
|
if detach {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if tty {
|
||||||
|
if err := HandleConsoleResize(ctx, process, con); err != nil {
|
||||||
|
logrus.WithError(err).Error("console resize")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sigc := commands.ForwardAllSignals(ctx, process)
|
||||||
|
defer commands.StopCatch(sigc)
|
||||||
|
}
|
||||||
status := <-statusC
|
status := <-statusC
|
||||||
code, _, err := status.Result()
|
code, _, err := status.Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user