Sfoglia il codice sorgente

check that stdin/stdout are ttys

Jan Klemkow 6 anni fa
parent
commit
689ed5ecf3
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  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>");