用途
isatty():
$ man isattyISATTY(3) Linux Programmer's Manual ISATTY(3)NAME isatty - does this descriptor refer to a terminalSYNOPSIS #include <unistd.h> int isatty(int desc);DEscriptION returns 1 if desc is an open file descriptor connected to a terminal and 0 otherwise.
由于
stdout始终是文件描述符1,因此您可以执行以下操作:
if(isatty(1)) // stdout is a terminal



