From: Brian Osman Newsgroups: comp.os.msdos.djgpp Subject: Re: Is stdout the console? Date: Fri, 28 Feb 1997 11:11:24 -0500 Organization: Rensselaer Polytechnic Institute, Troy NY, USA Lines: 27 Message-ID: <331703AC.5552@rpi.edu> References: <01IFXYQFJ23Q00I1MD AT cc DOT uab DOT es> Reply-To: osmanb AT rpi DOT edu NNTP-Posting-Host: darkwing.stu.rpi.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp X DOT PONS AT UAB DOT ES wrote: > > I need to know if stdout is the console, i.e., if it has not been > redirected to a file through > > MY_PROGRAM > FILE > > In TC, I do it by checking the field "flag" of the FILE structute associated > with stdout: if stdout is the console, this flag indicates _F_TERM. > In DJGPP the FILE structure semms to be different and I cannot find this > flag. In fact, if you know some other portable way to know if stdout is the > console or a file it will also be useful to me. > > Thanks in advance! > > XP Hmmm. Right now I can't think exactly what you'd look for, but I'm sure you could figure it out somehow with stat(). I was thinking you could try opening it for read only, but I've heard from some people that (at least on some systems) stdout and stdin can both be opened the wrong way... :) Try stat() and checking some of the different flags for file types, and see what you get when it is/isn't redirected. (Or, write soemthing and look in the video memory for it. Ouch, that's an evil suggestion.) Brian