Skip to content

Commit

Permalink
rootlessport: drop Pdeathsig in favor of Kill
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
giuseppe committed Feb 12, 2020
1 parent 2550ded commit 5b69e7f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/rootlessport/rootlessport_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 5b69e7f

Please sign in to comment.