Fix panic for task in unknown state.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
b5ec5ee4f6
commit
c6203ec13b
@ -105,6 +105,7 @@ func (c *ContainerIO) Config() cio.Config {
|
||||
// to output stream.
|
||||
func (c *ContainerIO) Pipe() {
|
||||
wg := c.closer.wg
|
||||
if c.stdout != nil {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if _, err := io.Copy(c.stdoutGroup, c.stdout); err != nil {
|
||||
@ -115,8 +116,9 @@ func (c *ContainerIO) Pipe() {
|
||||
wg.Done()
|
||||
logrus.Infof("Finish piping stdout of container %q", c.id)
|
||||
}()
|
||||
}
|
||||
|
||||
if !c.fifos.Terminal {
|
||||
if !c.fifos.Terminal && c.stderr != nil {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if _, err := io.Copy(c.stderrGroup, c.stderr); err != nil {
|
||||
|
@ -120,17 +120,21 @@ func newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, _ *wgCloser, err error) {
|
||||
set = append(set, f)
|
||||
}
|
||||
|
||||
if fifos.Stdout != "" {
|
||||
if f, err = fifo.OpenFifo(ctx, fifos.Stdout, syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
p.stdout = f
|
||||
set = append(set, f)
|
||||
}
|
||||
|
||||
if fifos.Stderr != "" {
|
||||
if f, err = fifo.OpenFifo(ctx, fifos.Stderr, syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0700); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
p.stderr = f
|
||||
set = append(set, f)
|
||||
}
|
||||
|
||||
return p, &wgCloser{
|
||||
wg: &sync.WaitGroup{},
|
||||
|
Loading…
Reference in New Issue
Block a user