Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ isatty(DOS) — OpenDesktop Software Development System 1.0.0d

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     Name
          isatty - Identifies a character device.

     Syntax
          #include <io.h>

          int isatty(handle)
          int handle;

     Description
          The isatty function determines whether handle is associated
          with a character device (that is, a terminal, console,
          printer, or serial port).

     Return Value
          The isatty function returns a nonzero value if the device is
          a character device. Otherwise, the return value is 0.

     Example
          #include <stdio.h> #include <io.h>

          long loc;

          main() {
                  int interactive;

                  interactive = isatty(fileno(stdout));
                  printf("Is stdout redirected? %s\n",
                          interactive ? "no" : "yes");

                  /* if not a character device,   **
                  ** get current position     */

                  if (!interactive)
                  loc = tell(fileno(stdout)); }

          This program checks to see whether stdout has been
          redirected to a file.  For example, if the program was
          invoked as

            sample > output

          then

            isatty(fileno(stdout))

          would return false because stdout is actually the file
          output.  If the program is invoked as

            sample

          however, then the call to isatty would return true, because
          stdout is still directed to the screen.

                                                (printed 6/18/89)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026