ISATTY(3C) Standard C Library Functions ISATTY(3C)

NAME


isatty - test for a terminal device

LIBRARY


Standard C Library (libc, -lc)

SYNOPSIS


#include <unistd.h>

int
isatty(int filedes);

DESCRIPTION


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

RETURN VALUES


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

ERRORS


The isatty() function may fail if:

EBADF The fildes argument is not a valid open file
descriptor.

ENOTTY The fildes argument is not associated with a
terminal.

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.

There are a few portability concerns to be aware of. POSIX does not
strictly require that the isatty() function actually set and update
errno. The only portable and reliable thing to do is to check the
return value. Older versions of this implementation did not set errno
and erroneously preserved errno when the isatty() function returned 0.
In cases where true portability is required, one should set errno to
zero before calling this function to potentially allow for and
distinguish this case.

INTERFACE STABILITY


Committed

MT-LEVEL
MT-Safe

SEE ALSO


ttyname(3C), attributes(7), standards(7)

illumos December 1, 2022 illumos

tribblix@gmail.com :: GitHub :: Privacy