]> git.ipfire.org Git - thirdparty/lxc.git/commit
namespace: add lxc_raw_clone()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Dec 2017 14:31:54 +0000 (15:31 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Dec 2017 21:18:28 +0000 (22:18 +0100)
commit8ab93249a05499eb06ed326bc6f4fd4a0e800cbc
tree57c992d9ea6c626a0c74093f90c15ffa09f944eb
parent2e3890af0fed18a53d3e255b37b690755bd887a8
namespace: add lxc_raw_clone()

This is based on raw_clone in systemd but adapted to our needs. The main reason
is that we need an implementation of fork()/clone() that does guarantee us that
no pthread_atfork() handlers are run. While clone() in glibc currently doesn't
run pthread_atfork() handlers we should be fine but there's no guarantee that
this won't be the case in the future. So let's do the syscall directly - or as
direct as we can. An additional nice feature is that we get fork() behavior,
i.e. lxc_raw_clone() returns 0 in the child and the child pid in the parent.

Our implementation tries to make sure that we cover all cases according to
kernel sources. Note that we are not interested in any arguments that could be
passed after the stack.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/namespace.c
src/lxc/namespace.h
src/tests/Makefile.am
src/tests/lxc_raw_clone.c [new file with mode: 0644]