Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

62. Terminals > Terminal Identification

Terminal Identification

In Controlling Terminals and Controlling Processes, we described the ctermid() function, which returns the name of the controlling terminal for a process (usually /dev/tty on UNIX systems). The functions described in this section are also useful for identifying a terminal.

The isatty() function enables us to determine whether a file descriptor, fd, is associated with a terminal (as opposed to some other file type).

#include <unistd.h>

int isatty(int fd);

Note

Returns true (1) if fd is associated with a terminal, otherwise false (0)

The isatty() function is useful in editors and other screen-handling programs that need to determine whether their standard input and output are directed to a terminal.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint