cttyhack: fail gracefully if the device node is missing
authorKevin Cernekee <cernekee@gmail.com>
Wed, 13 Jul 2011 07:30:36 +0000 (09:30 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 13 Jul 2011 07:30:36 +0000 (09:30 +0200)
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/cttyhack.c

index 522a1ba737ef062b0a4b0853913e3f137c3e30f7..4261289b45da7b8e58540cf59f40d1ebf1255ffb 100644 (file)
@@ -146,7 +146,9 @@ int cttyhack_main(int argc UNUSED_PARAM, char **argv)
                        goto ret;
                } while (0);
 
-               fd = xopen(console, O_RDWR);
+               fd = open_or_warn(console, O_RDWR);
+               if (fd < 0)
+                       goto ret;
                //bb_error_msg("switching to '%s'", console);
                dup2(fd, 0);
                dup2(fd, 1);