diff --git a/namespaces/exec.go b/namespaces/exec.go index e32da4b86..0aa2bb9c7 100644 --- a/namespaces/exec.go +++ b/namespaces/exec.go @@ -94,7 +94,9 @@ func Exec(container *libcontainer.Config, term Terminal, rootfs, dataPath string defer libcontainer.DeleteState(dataPath) // Sync with child - if err := syncPipe.BlockOnChild(); err != nil { + if err := syncPipe.ReadFromChild(); err != nil { + command.Process.Kill() + command.Wait() return -1, err } diff --git a/namespaces/init.go b/namespaces/init.go index 4a6ce6e3a..53d2611b8 100644 --- a/namespaces/init.go +++ b/namespaces/init.go @@ -30,7 +30,7 @@ import ( func Init(container *libcontainer.Config, uncleanRootfs, consolePath string, syncPipe *SyncPipe, args []string) (err error) { defer func() { if err != nil { - syncPipe.ReportError(err) + syncPipe.ReportChildError(err) } }() diff --git a/namespaces/sync_pipe.go b/namespaces/sync_pipe.go index ae6fefc30..2160243e4 100644 --- a/namespaces/sync_pipe.go +++ b/namespaces/sync_pipe.go @@ -60,10 +60,10 @@ func (s *SyncPipe) SendToChild(networkState *network.NetworkState) error { return nil } -func (s *SyncPipe) BlockOnChild() error { +func (s *SyncPipe) ReadFromChild() error { data, err := ioutil.ReadAll(s.parent) if err != nil { - return nil + return err } if len(data) > 0 { return fmt.Errorf("Child error: %s", string(data)) @@ -86,7 +86,7 @@ func (s *SyncPipe) ReadFromParent() (*network.NetworkState, error) { } -func (s *SyncPipe) ReportError(err error) { +func (s *SyncPipe) ReportChildError(err error) { s.child.Write([]byte(err.Error())) s.CloseChild() }