isatty man page


This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

isatty — test for a terminal device


#include <unistd.h>

int isatty(int fildes);


The isatty() function shall test whether fildes, an open file descriptor, is associated with a terminal device.

Return Value

The isatty() function shall return 1 if fildes is associated with a terminal; otherwise, it shall return 0 and may set errno to indicate the error.


The isatty() function may fail if:

The fildes argument is not a valid open file descriptor.
The file associated with the fildes argument is not a terminal.

The following sections are informative.

Application Usage

The isatty() function does not necessarily indicate that a human being is available for interaction via fildes. It is quite possible that non-terminal devices are connected to the communications line.

See Also

The Base Definitions volume of POSIX.1‐2008, <unistd.h>