← Commit list

e3b65ab43

Andrei Gherzan
Andrei Gherzan
2017-03-24
SUCCESS Duration: 245s

Subject

switch_root: don't bail out when console doesn't exist

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

util-linux/switch_root.c+6 -4
@@ -141,10 +141,12 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
// If a new console specified, redirect stdin/stdout/stderr to it
if (console) {
- close(0);
- xopen(console, O_RDWR);
- xdup2(0, 1);
- xdup2(0, 2);
+ int fd = open_or_warn(console, O_RDWR);
+ if (fd >= 0) {
+ xmove_fd(fd, 0);
+ xdup2(0, 1);
+ xdup2(0, 2);
+ }
}
// Exec real init