|
isatty()是这样描述的:
Test to see if a file descriptor is associated with a terminal. <---请解释这句话的意思?
这是例子,可能帮助大家理解
- #cat example.c
- #include <unistd.h>
- #include <stdio.h>
- int
- main(void)
- {
- printf("fd 0 : %s\n", isatty(0) ? "tty" : "not a tty");
- printf("fd 1 : %s\n", isatty(1) ? "tty" : "not a tty");
- printf("fd 2 : %s\n", isatty(2) ? "tty" : "not a tty");
- exit(0);
- }
复制代码
#gcc example.c
#./a.out
:thank |
|