]> git.ipfire.org Git - thirdparty/lxc.git/commit
lxc_attach: Use clone() instead of second fork()
authorChristian Seiler <christian@iwakd.de>
Thu, 25 Apr 2013 11:00:19 +0000 (13:00 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 25 Apr 2013 16:17:53 +0000 (18:17 +0200)
commit4f43438c476c3c5fb78d6192238d540108a33cb1
treef30400021161ff8163a43f2cb864c6fb6ed85558
parent6320e49454b0fd86dde7df0af54a2e194ae59821
lxc_attach: Use clone() instead of second fork()

Because of an assertion in glibc's fork() wrapper that parent pid and
pid of child should never be the same, one should avoid fork() after
attaching to a PID namespace, since the pid inside the namespace may
coincide with the pid of the parent outside the namespace, thus hitting
the aforementioned assertion.

This patch just changes the code in the most simple manner to use
clone() instead of fork(). Since clone() requires a function to be
called instead of returning 0, we move the code of the child into a
function child_main.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc_attach.c