summaryrefslogtreecommitdiff
path: root/src/core/main.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-07-10 19:19:59 +0200
committerLennart Poettering <lennart@poettering.net>2012-07-10 19:19:59 +0200
commitcd3bd60a2e4bb08526d953a323bbe1a0ace78b9e (patch)
tree465cfcaa0896697ed0f0e7d4e144f9d4f1ffbbe3 /src/core/main.c
parent94163dd54328780b4539e7296eb0ba75b7290367 (diff)
switch-root: reopen /dev/console before we switch root
Diffstat (limited to 'src/core/main.c')
-rw-r--r--src/core/main.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 6a2dbc2f54..6f6b565d68 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -164,16 +164,11 @@ _noreturn_ static void crash(int sig) {
sa.sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT|SA_RESTART;
assert_se(sigaction(SIGCHLD, &sa, NULL) == 0);
- if ((pid = fork()) < 0)
+ pid = fork();
+ if (pid < 0)
log_error("Failed to fork off crash shell: %s", strerror(errno));
else if (pid == 0) {
- int fd, r;
-
- if ((fd = acquire_terminal("/dev/console", false, true, true, (usec_t) -1)) < 0)
- log_error("Failed to acquire terminal: %s", strerror(-fd));
- else if ((r = make_stdio(fd)) < 0)
- log_error("Failed to duplicate terminal fd: %s", strerror(-r));
-
+ make_console_stdio();
execl("/bin/sh", "/bin/sh", NULL);
log_error("execl() failed: %s", strerror(errno));
@@ -1677,6 +1672,9 @@ finish:
* rebooted while we do that */
watchdog_close(true);
+ /* Reopen the console */
+ make_console_stdio();
+
if (switch_root_dir) {
r = switch_root(switch_root_dir);
if (r < 0)