Tito sent more size tweaks.
authorRob Landley <rob@landley.net>
Thu, 8 Sep 2005 03:27:06 +0000 (03:27 -0000)
committerRob Landley <rob@landley.net>
Thu, 8 Sep 2005 03:27:06 +0000 (03:27 -0000)
console-tools/chvt.c
console-tools/deallocvt.c
console-tools/openvt.c
console-tools/setconsole.c

index 3398892f5e0a3c2dd7c5e02066538def6b9d2731..b1a429eb38ce21f1a233fb4d451fca5b9a67629a 100644 (file)
@@ -42,11 +42,9 @@ int chvt_main(int argc, char **argv)
 
        fd = get_console_fd();
        num =  bb_xgetlarg(argv[1], 10, 0, INT_MAX);
-       if (ioctl(fd, VT_ACTIVATE, num)) {
-               bb_perror_msg_and_die("VT_ACTIVATE");
-       }
-       if (ioctl(fd, VT_WAITACTIVE, num)) {
-               bb_perror_msg_and_die("VT_WAITACTIVE");
+       if((-1 == ioctl(fd, VT_ACTIVATE, num)) ||
+          (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
+               bb_perror_msg_and_die("ioctl");
        }
        return EXIT_SUCCESS;
 }
index 08a9d2122e17670d1b67b40d3d741659cd06c74b..00ddf42369a2551bf04d4b48c19846850dfeafd6 100644 (file)
@@ -42,14 +42,14 @@ int deallocvt_main(int argc, char *argv[])
                case 2:
                        if((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0)
                                bb_error_msg_and_die("0: illegal VT number");
-               /* Falltrough */
+               /* Fallthrough */
                case 1:
                        break;
                default:
                        bb_show_usage();
        }
 
-       if (ioctl( get_console_fd(), VT_DISALLOCATE, num )) {
+       if (-1 == ioctl( get_console_fd(), VT_DISALLOCATE, num )) {
                bb_perror_msg_and_die("VT_DISALLOCATE");
        }
        return EXIT_SUCCESS;
index 5f244579c7f292fc1bfb518e03aed81e4b288b5b..d9f49bbead77d4203b86ed82fab081295ae5288b 100644 (file)
@@ -64,10 +64,8 @@ int openvt_main(int argc, char **argv)
                fd = bb_xopen(vtname, O_RDWR);
 
                /* Reassign stdout and sterr */
-               close(1);
-               close(2);
-               dup(fd);
-               dup(fd);
+               dup2(fd, STDOUT_FILENO);
+               dup2(fd, STDERR_FILENO);
 
                execvp(argv[0], argv);
                _exit(1);
index 53ff1ad1edc5328b859b22aaffebcfa801f87e55..5806f21ede44db808d4edba28afcea2d5685f470 100644 (file)
@@ -37,9 +37,8 @@ static const struct option setconsole_long_options[] = {
 
 int setconsole_main(int argc, char **argv)
 {
-       int con;
        unsigned long flags;
-       const char *device = "/dev/tty";
+       const char *device = CURRENT_TTY;
 
        bb_applet_long_options = setconsole_long_options;
        flags = bb_getopt_ulflags(argc, argv, "r");
@@ -53,14 +52,11 @@ int setconsole_main(int argc, char **argv)
                device = argv[optind];
        } else {
                if (flags & OPT_SETCONS_RESET)
-                       device = "/dev/console";
+                       device = CONSOLE_DEV;
        }
 
-       if (-1 == (con = open(device, O_RDONLY))) {
-               bb_perror_msg_and_die("open %s", device);
-       }
-       if (-1 == ioctl(con, TIOCCONS)) {
-               bb_perror_msg_and_die("ioctl TIOCCONS");
+       if (-1 == ioctl(bb_xopen(device, O_RDONLY), TIOCCONS)) {
+               bb_perror_msg_and_die("TIOCCONS");
        }
        return EXIT_SUCCESS;
 }