[Previous]
[Contents]
[Next]

isatty()

test to see if a file descriptor is associated with a terminal

Synopsis:

#include <unistd.h>
int isatty( int fildes );

Description:

The isatty() function allows the calling process to determine if the file descriptor fildes is associated with a terminal.

Returns:

0
fildes doesn't refer to a terminal
1
fildes refers to a terminal

Examples:

/*
 * The following program exits with a status of
 * EXIT_SUCCESS if stderr is a tty, otherwise
 * EXIT_FAILURE
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void main()
  {
    exit( isatty( 3 ) ? EXIT_SUCCESS : EXIT_FAILURE );
  }

Classification:

POSIX 1003.1

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

open()


[Previous]
[Contents]
[Next]