d.p[1] = p[1];
/* Clone child in new user namespace. */
- pid = lxc_clone(run_userns_fn, &d, CLONE_NEWUSER);
+ pid = lxc_clone(run_userns_fn, &d, CLONE_NEWUSER, NULL);
if (pid < 0) {
ERROR("Failed to clone process in new user namespace");
goto on_error;
}
#define __LXC_STACK_SIZE 4096
-pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
+pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd)
{
size_t stack_size;
pid_t ret;
stack_size = __LXC_STACK_SIZE;
#ifdef __ia64__
- ret = __clone2(do_clone, stack, stack_size, flags | SIGCHLD, &clone_arg);
+ ret = __clone2(do_clone, stack, stack_size, flags | SIGCHLD, &clone_arg, pidfd);
#else
- ret = clone(do_clone, stack + stack_size, flags | SIGCHLD, &clone_arg);
+ ret = clone(do_clone, stack + stack_size, flags | SIGCHLD, &clone_arg, pidfd);
#endif
if (ret < 0)
SYSERROR("Failed to clone (%#x)", flags);
* - should call lxc_raw_getpid():
* The child should use lxc_raw_getpid() to retrieve its pid.
*/
-extern pid_t lxc_clone(int (*fn)(void *), void *arg, int flags);
+extern pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd);
extern int lxc_namespace_2_cloneflag(const char *namespace);
extern int lxc_namespace_2_ns_idx(const char *namespace);
pid_t attacher_pid;
attacher_pid = lxc_clone(do_share_ns, handler,
- CLONE_VFORK | CLONE_VM | CLONE_FILES);
+ CLONE_VFORK | CLONE_VM | CLONE_FILES, NULL);
if (attacher_pid < 0) {
SYSERROR(LXC_CLONE_ERROR);
goto out_delete_net;
data.nbd = nbd;
data.path = path;
- pid = lxc_clone(do_attach_nbd, &data, CLONE_NEWPID);
+ pid = lxc_clone(do_attach_nbd, &data, CLONE_NEWPID, NULL);
if (pid < 0)
return false;
start_arg.want_hostname = my_args.want_hostname;
start_arg.want_default_mounts = my_args.want_default_mounts;
- pid = lxc_clone(do_start, &start_arg, my_args.flags);
+ pid = lxc_clone(do_start, &start_arg, my_args.flags, NULL);
if (pid < 0) {
ERROR("Failed to clone");
free_ifname_list();