summaryrefslogtreecommitdiff
path: root/src/core/shutdown.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/shutdown.c')
-rw-r--r--src/core/shutdown.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index baef66dd9d..194a1ccf21 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -267,9 +267,10 @@ static int prepare_new_root(void) {
}
static int pivot_to_new_root(void) {
- int fd;
-
- chdir("/run/initramfs");
+ if (chdir("/run/initramfs") < 0) {
+ log_error("Failed to change directory to /run/initramfs: %m");
+ return -errno;
+ }
/*
In case some evil process made "/" MS_SHARED
@@ -288,18 +289,11 @@ static int pivot_to_new_root(void) {
}
chroot(".");
- log_info("Successfully changed into root pivot.");
- fd = open("/dev/console", O_RDWR);
- if (fd < 0)
- log_error("Failed to open /dev/console: %m");
- else {
- make_stdio(fd);
+ setsid();
+ make_console_stdio();
- /* Initialize the controlling terminal */
- setsid();
- ioctl(STDIN_FILENO, TIOCSCTTY, NULL);
- }
+ log_info("Successfully changed into root pivot.");
return 0;
}