struct namespace_file *nsfile;
int c, namespaces = 0;
- bool do_rd = false, do_wd = false, do_fork = false;
+ bool do_rd = false, do_wd = false;
+ int do_fork = -1; /* unknown yet */
setlocale(LC_MESSAGES, "");
bindtextdomain(PACKAGE, LOCALEDIR);
namespaces |= CLONE_NEWNET;
break;
case 'p':
- do_fork = true;
if (optarg)
open_namespace_fd(CLONE_NEWPID, optarg);
else
namespaces |= CLONE_NEWUSER;
break;
case 'F':
- do_fork = false;
+ do_fork = 0;
break;
case 'r':
if (optarg)
for (nsfile = namespace_files; nsfile->nstype; nsfile++) {
if (nsfile->fd < 0)
continue;
+ if (nsfile->nstype == CLONE_NEWPID && do_fork == -1)
+ do_fork = 1;
if (setns(nsfile->fd, nsfile->nstype))
err(EXIT_FAILURE,
_("reassociate to namespace '%s' failed"),
wd_fd = -1;
}
- if (do_fork)
+ if (do_fork == 1)
continue_as_child();
execvp(argv[optind], argv + optind);