Check if 0, 1, 2 are valid tty file descriptors - ubase - suckless linux base utils
HTML git clone git://git.suckless.org/ubase
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 2d45a04b92df641158ca400873a522fede1d9a01
DIR parent 6da76775cb54635ce07dfcd3894cdef3df8c692f
HTML Author: sin <sin@2f30.org>
Date: Sun, 30 Nov 2014 13:04:47 +0000
Check if 0, 1, 2 are valid tty file descriptors
Diffstat:
M login.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
DIR diff --git a/login.c b/login.c
@@ -71,8 +71,8 @@ main(int argc, char *argv[])
if (argc < 1)
usage();
- if (isatty(STDIN_FILENO) == 0)
- eprintf("stdin is not a tty\n");
+ if (isatty(0) == 0 || isatty(1) == 0 || isatty(2) == 0)
+ eprintf("no tty");
user = argv[0];
errno = 0;