mirror of
https://github.com/containers/podman.git
synced 2025-06-19 00:06:43 +08:00
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>
This commit is contained in:
@ -149,9 +149,6 @@ func parent() error {
|
|||||||
cmd.Stdout = &logrusWriter{prefix: "child"}
|
cmd.Stdout = &logrusWriter{prefix: "child"}
|
||||||
cmd.Stderr = cmd.Stdout
|
cmd.Stderr = cmd.Stdout
|
||||||
cmd.Env = append(os.Environ(), reexecChildEnvOpaque+"="+string(opaqueJSON))
|
cmd.Env = append(os.Environ(), reexecChildEnvOpaque+"="+string(opaqueJSON))
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
|
||||||
Pdeathsig: syscall.SIGTERM,
|
|
||||||
}
|
|
||||||
childNS, err := ns.GetNS(cfg.NetNSPath)
|
childNS, err := ns.GetNS(cfg.NetNSPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -163,6 +160,12 @@ func parent() error {
|
|||||||
return err
|
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")
|
logrus.Info("waiting for initComplete")
|
||||||
// wait for the child to connect to the parent
|
// wait for the child to connect to the parent
|
||||||
outer:
|
outer:
|
||||||
|
Reference in New Issue
Block a user