summaryrefslogtreecommitdiff
path: root/pkg/rootlessport/rootlessport_linux.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-03-12 11:39:10 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2020-03-12 11:39:13 +0100
commit647dc33e1ad967ade50d803816366a2a944691de (patch)
tree5a374f6b0726fbaf4acab9f214cf6c98933ae63f /pkg/rootlessport/rootlessport_linux.go
parent78e090092b38ab52993a3eec6d9bab0eabeaa1fc (diff)
downloadpodman-647dc33e1ad967ade50d803816366a2a944691de.tar.gz
podman-647dc33e1ad967ade50d803816366a2a944691de.tar.bz2
podman-647dc33e1ad967ade50d803816366a2a944691de.zip
rootlessport: detect rootless-child exit
otherwise the rootless parent process might wait indefinitely when the rootless-child process exits early. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/rootlessport/rootlessport_linux.go')
-rw-r--r--pkg/rootlessport/rootlessport_linux.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/rootlessport/rootlessport_linux.go b/pkg/rootlessport/rootlessport_linux.go
index 2b51f4e09..febfc2268 100644
--- a/pkg/rootlessport/rootlessport_linux.go
+++ b/pkg/rootlessport/rootlessport_linux.go
@@ -160,6 +160,13 @@ func parent() error {
return err
}
+ childErrCh := make(chan error)
+ go func() {
+ err := cmd.Wait()
+ childErrCh <- err
+ close(childErrCh)
+ }()
+
defer func() {
if err := syscall.Kill(cmd.Process.Pid, syscall.SIGTERM); err != nil {
logrus.WithError(err).Warn("kill child process")
@@ -174,6 +181,10 @@ outer:
case <-initComplete:
logrus.Infof("initComplete is closed; parent and child established the communication channel")
break outer
+ case err := <-childErrCh:
+ if err != nil {
+ return err
+ }
case err := <-errCh:
if err != nil {
return err