summaryrefslogtreecommitdiff
path: root/pkg/rootlessport
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-02-12 18:39:30 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2020-02-12 18:48:42 +0100
commit5b69e7f2ef3ad0bd73ad6ec4d24c033da6456ef2 (patch)
tree5acaae14b77e9f94e9da68d9cc60a584b008ab38 /pkg/rootlessport
parent2550ded989efc889da1785b07865815b7e1b9415 (diff)
downloadpodman-5b69e7f2ef3ad0bd73ad6ec4d24c033da6456ef2.tar.gz
podman-5b69e7f2ef3ad0bd73ad6ec4d24c033da6456ef2.tar.bz2
podman-5b69e7f2ef3ad0bd73ad6ec4d24c033da6456ef2.zip
rootlessport: drop Pdeathsig in favor of Kill
there is a race condition where the child process is immediately killed: [pid 2576752] arch_prctl(0x3001 /* ARCH_??? */, 0x7ffdf612f170) = -1 EINVAL (Invalid argument) [pid 2576752] access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) [pid 2576752] --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=2576742, si_uid=0} --- [pid 2576752] +++ killed by SIGTERM +++ this happens because the parent process here really means the "parent thread". Since there is no way of running it on the main thread, let's skip this functionality altogether and use kill(2). Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/rootlessport')
-rw-r--r--pkg/rootlessport/rootlessport_linux.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/rootlessport/rootlessport_linux.go b/pkg/rootlessport/rootlessport_linux.go
index acdf3198b..2b51f4e09 100644
--- a/pkg/rootlessport/rootlessport_linux.go
+++ b/pkg/rootlessport/rootlessport_linux.go
@@ -149,9 +149,6 @@ func parent() error {
cmd.Stdout = &logrusWriter{prefix: "child"}
cmd.Stderr = cmd.Stdout
cmd.Env = append(os.Environ(), reexecChildEnvOpaque+"="+string(opaqueJSON))
- cmd.SysProcAttr = &syscall.SysProcAttr{
- Pdeathsig: syscall.SIGTERM,
- }
childNS, err := ns.GetNS(cfg.NetNSPath)
if err != nil {
return err
@@ -163,6 +160,12 @@ func parent() error {
return err
}
+ defer func() {
+ if err := syscall.Kill(cmd.Process.Pid, syscall.SIGTERM); err != nil {
+ logrus.WithError(err).Warn("kill child process")
+ }
+ }()
+
logrus.Info("waiting for initComplete")
// wait for the child to connect to the parent
outer: