www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/04/21/23:12:19

Date: Fri, 21 Apr 95 21:19:06 EDT
From: peprbv AT cfa0 DOT harvard DOT edu (Bob Babcock)
To: bob AT xnet DOT com
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: TTY Flags
Reply-To: babcock AT cfa DOT harvard DOT edu

> is there another way to check if output is to the screen/input from the
> keyboard?

Here's how I check whether input has been redirected:
    Redirected = !(ioctl(0,0) & 0x80);
The first 0 is the handle (so for stdout, you would use ioctl(1,0)).  The
second 0 means get device information.  According to Ralf Brown's interrupt
list, the bit being tested indicates that the "file is remote (DOS 3+)".
Beyond this, I don't know why this code fragment works.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019