Add/improve comment, shorten some usage texts. No code changes.
[oweals/busybox.git] / loginutils / vlock.c
index d472c09251d788311f8ce89b23de43fd0beec7c0..06a7169d9b5e444c7b790cfd6e1bb77b2cb60e4d 100644 (file)
@@ -27,10 +27,7 @@ static unsigned long o_lock_all;
 
 static void release_vt(int signo)
 {
-       if (!o_lock_all)
-               ioctl(vfd, VT_RELDISP, 1);
-       else
-               ioctl(vfd, VT_RELDISP, 0);
+       ioctl(vfd, VT_RELDISP, !o_lock_all);
 }
 
 static void acquire_vt(int signo)
@@ -44,22 +41,24 @@ static void restore_terminal(void)
        tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
 }
 
+int vlock_main(int argc, char **argv);
 int vlock_main(int argc, char **argv)
 {
        sigset_t sig;
        struct sigaction sa;
        struct vt_mode vtm;
        struct termios term;
+       uid_t uid = getuid();
+
+       pw = getpwuid(uid);
+       if (pw == NULL)
+               bb_error_msg_and_die("unknown uid %d", uid);
 
        if (argc > 2) {
                bb_show_usage();
        }
 
-       o_lock_all = bb_getopt_ulflags (argc, argv, "a");
-
-       if((pw = getpwuid(getuid())) == NULL) {
-               bb_error_msg_and_die("Unknown uid %d", getuid());
-       }
+       o_lock_all = getopt32(argc, argv, "a");
 
        vfd = xopen(CURRENT_TTY, O_RDWR);
 
@@ -116,5 +115,5 @@ int vlock_main(int argc, char **argv)
                puts("Password incorrect");
        } while (1);
        restore_terminal();
-       return 0;
+       fflush_stdout_and_exit(0);
 }