소스 검색

check that stdin/stdout are ttys

Jan Klemkow 6 년 전
부모
커밋
689ed5ecf3
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  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>");