top: add -m ("memory") option
[oweals/busybox.git] / loginutils / vlock.c
index ff60d78ffe5c5fc698bb67020eaf5078928a7110..85f489c2286d1b5574e5a339139be1941c7fb391 100644 (file)
 #include <sys/vt.h>
 #include "libbb.h"
 
-static void release_vt(int signo)
+static void release_vt(int signo UNUSED_PARAM)
 {
        /* If -a, param is 0, which means:
         * "no, kernel, we don't allow console switch away from us!" */
        ioctl(STDIN_FILENO, VT_RELDISP, (unsigned long) !option_mask32);
 }
 
-static void acquire_vt(int signo)
+static void acquire_vt(int signo UNUSED_PARAM)
 {
        /* ACK to kernel that switch to console is successful */
        ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ);
 }
 
 int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int vlock_main(int argc, char **argv)
+int vlock_main(int argc UNUSED_PARAM, char **argv)
 {
        struct vt_mode vtm;
        struct termios term;
        struct termios oterm;
        struct vt_mode ovtm;
-       uid_t uid;
        struct passwd *pw;
 
-       uid = getuid();
-       pw = getpwuid(uid);
-       if (pw == NULL)
-               bb_error_msg_and_die("unknown uid %d", (int)uid);
-
+       pw = xgetpwuid(getuid());
        opt_complementary = "=0"; /* no params! */
        getopt32(argv, "a");
 
@@ -87,7 +82,7 @@ int vlock_main(int argc, char **argv)
        term.c_iflag |= IGNBRK;
        term.c_lflag &= ~ISIG;
        term.c_lflag &= ~(ECHO | ECHOCTL);
-       tcsetattr(STDIN_FILENO, TCSANOW, &term);
+       tcsetattr_stdin_TCSANOW(&term);
 
        do {
                printf("Virtual console%s locked by %s.\n",
@@ -101,6 +96,6 @@ int vlock_main(int argc, char **argv)
        } while (1);
 
        ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
-       tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
-       fflush_stdout_and_exit(0);
+       tcsetattr_stdin_TCSANOW(&oterm);
+       fflush_stdout_and_exit(EXIT_SUCCESS);
 }