diff options
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r-- | sys-utils/switch_root.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index 75725e707..1de3a2e58 100644 --- a/sys-utils/switch_root.c +++ b/sys-utils/switch_root.c @@ -114,6 +114,7 @@ static int switchroot(const char *newroot) const char *umounts[] = { "/dev", "/proc", "/sys", NULL }; int i; int cfd; + pid_t pid; for (i = 0; umounts[i] != NULL; i++) { char newmount[PATH_MAX]; @@ -135,7 +136,12 @@ static int switchroot(const char *newroot) cfd = open("/", O_RDONLY); if (cfd >= 0) { - recursiveRemove(cfd); + pid = fork(); + if (pid <= 0) { + recursiveRemove(cfd); + if (pid == 0) + exit(EXIT_SUCCESS); + } close(cfd); } |