Explorar o código

check that stdin/stdout are ttys

Jan Klemkow %!s(int64=6) %!d(string=hai) anos
pai
achega
689ed5ecf3
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      scroll.c

+ 5 - 0
scroll.c

@@ -123,6 +123,11 @@ scrollup(void)
 int
 main(int argc, char *argv[])
 {
+	if (isatty(STDIN_FILENO) == 0)
+		die("stdin it not a tty");
+	if (isatty(STDOUT_FILENO) == 0)
+		die("stdout it not a tty");
+
 	if (argc <= 1)
 		die("usage: scroll <program>");