-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Linux System Programming Techniques
By :

In this recipe, we'll start looking at some of the C functions to examine TTYs. Here, we mean TTY in the broadest sense, meaning both TTY and PTY.
The program we will write here will check if stdout is a terminal. If it's not, it will print an error message.
Knowing how to check if stdin, stdout, or stderr are terminal devices will enable you to write error checks for programs that require a terminal to work.
For this recipe, we'll need the GCC compiler, the Make tool, and the generic Makefile. The generic Makefile can be downloaded from this chapter's GitHub folder, at https://github.com/PacktPublishing/Linux-System-Programming-Techniques/tree/master/ch9.
Here, we'll write a small program that prints an error message if stdout is not a terminal:
ttyinfo.c
. We use two new functions here. The first one is isatty...