#include <unistd.h>
int isatty(int fd);
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void isatty_printer(const int fd)
{
if (isatty(fd))
printf ("Yes, it is a tty\n");
else
printf ("No, it is not a tty\n");
}
int main()
{
int fd = 100;
isatty_printer(fd);
fd = STDIN_FILENO;
isatty_printer(fd);
fd = open("/dev/tty", O_RDONLY);
isatty_printer(fd);
return 0;
}
./isatty
No, it is not a tty
Yes, it is a tty
Yes, it is a tty
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |