aboutsummaryrefslogtreecommitdiff
path: root/util-linux/unshare.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/unshare.c')
-rw-r--r--util-linux/unshare.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/util-linux/unshare.c b/util-linux/unshare.c
index 2a5bea5a6..95a7cb647 100644
--- a/util-linux/unshare.c
+++ b/util-linux/unshare.c
@@ -281,7 +281,7 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
281 281
282 if (fdp.wr >= 0) { 282 if (fdp.wr >= 0) {
283 close(fdp.wr); /* Release child */ 283 close(fdp.wr); /* Release child */
284 /*close(fdp.rd);*/ 284 close(fdp.rd); /* should close fd, to not confuse exec'ed PROG */
285 } 285 }
286 286
287 if (need_mount) { 287 if (need_mount) {
@@ -307,14 +307,7 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
307 * that'll become PID 1 in this new namespace. 307 * that'll become PID 1 in this new namespace.
308 */ 308 */
309 if (opts & OPT_fork) { 309 if (opts & OPT_fork) {
310 pid_t pid = xfork(); 310 xvfork_parent_waits_and_exits();
311 if (pid > 0) {
312 /* Parent */
313 int exit_status = wait_for_exitstatus(pid);
314 if (WIFSIGNALED(exit_status))
315 kill_myself_with_sig(WTERMSIG(exit_status));
316 return WEXITSTATUS(exit_status);
317 }
318 /* Child continues */ 311 /* Child continues */
319 } 312 }
320 313
@@ -354,11 +347,5 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
354 mount_or_die("proc", proc_mnt_target, "proc", MS_NOSUID | MS_NOEXEC | MS_NODEV); 347 mount_or_die("proc", proc_mnt_target, "proc", MS_NOSUID | MS_NOEXEC | MS_NODEV);
355 } 348 }
356 349
357 if (argv[0]) { 350 exec_prog_or_SHELL(argv);
358 BB_EXECVP_or_die(argv);
359 }
360 /* unshare from util-linux 2.27.1, despite not documenting it,
361 * runs a login shell (argv0="-sh") if no PROG is given
362 */
363 run_shell(getenv("SHELL"), /*login:*/ 1, NULL, NULL);
364} 351}