[hackers] [ubase] Check if stdin is a tty || sin

From: <git_AT_suckless.org>
Date: Tue, 03 Jun 2014 11:50:46 +0200

commit c4c1feac2a7cba8b2c5282810a30b192d0e30623
Author: sin <sin_AT_2f30.org>
Date: Tue Jun 3 10:45:27 2014 +0100

    Check if stdin is a tty
    
    Some indentation changes as well.

diff --git a/login.c b/login.c
index 3c8d6e0..b9720e4 100644
--- a/login.c
+++ b/login.c
_AT_@ -38,6 +38,9 @@ main(int argc, char *argv[])
         if (argc < 1)
                 usage();
 
+ if (isatty(STDIN_FILENO) == 0)
+ eprintf("stdin is not a tty
");
+
         errno = 0;
         pw = getpwnam(argv[0]);
         if (errno)
_AT_@ -59,7 +62,7 @@ main(int argc, char *argv[])
                 goto login;
 
         /* Flush pending input */
- ioctl(STDIN_FILENO, TCFLSH, (void *)0);
+ ioctl(STDIN_FILENO, TCFLSH, (void *)0);
 
         pass = getpass("Password: ");
         putchar('
');
Received on Tue Jun 03 2014 - 11:50:46 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 03 2014 - 12:00:09 CEST