Add close stdin
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
277cc920a4
commit
a42eb9fd63
12 changed files with 358 additions and 157 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/containerd/util"
|
||||
"github.com/docker/docker/pkg/term"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -40,6 +41,7 @@ func main() {
|
|||
// or if runc exits before we hit the handler
|
||||
signals := make(chan os.Signal, 2048)
|
||||
signal.Notify(signals)
|
||||
setupLogger()
|
||||
// set the shim as the subreaper for all orphaned processes created by the container
|
||||
if err := util.SetSubreaper(1); err != nil {
|
||||
logrus.WithField("error", err).Fatal("shim: set as subreaper")
|
||||
|
@ -50,6 +52,11 @@ func main() {
|
|||
logrus.WithField("error", err).Fatal("shim: open exit pipe")
|
||||
}
|
||||
defer f.Close()
|
||||
control, err := os.OpenFile("control", syscall.O_RDWR, 0)
|
||||
if err != nil {
|
||||
logrus.WithField("error", err).Fatal("shim: open control pipe")
|
||||
}
|
||||
defer control.Close()
|
||||
p, err := newProcess(flag.Arg(0), flag.Arg(1), fexec, fcheckpoint)
|
||||
if err != nil {
|
||||
logrus.WithField("error", err).Fatal("shim: create new process")
|
||||
|
@ -57,6 +64,29 @@ func main() {
|
|||
if err := p.start(); err != nil {
|
||||
logrus.WithField("error", err).Fatal("shim: start process")
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
var msg, w, h int
|
||||
if _, err := fmt.Fscanf(control, "%d %d %d\n", &msg, &w, &h); err != nil {
|
||||
logrus.WithField("error", err).Error("shim: reading from control")
|
||||
}
|
||||
logrus.Info("got control message")
|
||||
switch msg {
|
||||
case 0:
|
||||
// close stdin
|
||||
p.shimIO.Stdin.Close()
|
||||
case 1:
|
||||
if p.console == nil {
|
||||
continue
|
||||
}
|
||||
ws := term.Winsize{
|
||||
Width: uint16(w),
|
||||
Height: uint16(h),
|
||||
}
|
||||
term.SetWinsize(p.console.Fd(), &ws)
|
||||
}
|
||||
}
|
||||
}()
|
||||
var exitShim bool
|
||||
for s := range signals {
|
||||
logrus.WithField("signal", s).Debug("shim: received signal")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue