Test to see if a file descriptor is associated with a terminal
#include <unistd.h> int isatty( int fildes );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The isatty() function allows the calling process to determine if the file descriptor fildes is associated with a terminal.
/* * 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> int main( void ) { return( isatty( 3 ) ? EXIT_SUCCESS : EXIT_FAILURE ); }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |