I write a helper command to do a fork, then unshare don't need the -f option.
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char **argv)
{
int pid;
if (argc == 1) {
fprintf(stderr, "invalid arguments\n");
return 1;
}
pid = fork();
if (pid < 0) {
fprintf(stderr, "fork failed: %s\n", strerror(errno));
return 1;
}
else if (pid == 0) {
execvp(argv[1], &argv[1]);
fprintf(stderr, "execvp failed: %s\n", strerror(errno));
return 1;
}
while (wait(NULL) != -1);
return 0;
}
then call like this
$ sudo unshare -p unshare-pid-start /bin/bash -i