Message-ID: <3E0F0CAE.CC28815F@yahoo.com> From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Detecting stdin not redirected References: <3E0EA6CF DOT 51896D97 AT yahoo DOT com> <3E0EDC94 DOT 421FD75E AT phekda DOT freeserve DOT co DOT uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 28 Date: Sun, 29 Dec 2002 14:55:07 GMT NNTP-Posting-Host: 12.90.174.194 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1041173707 12.90.174.194 (Sun, 29 Dec 2002 14:55:07 GMT) NNTP-Posting-Date: Sun, 29 Dec 2002 14:55:07 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Richard Dawe wrote: > CBFalconer wrote: > > > With gcc and DJGPP, how can a running program detect that stdin > > has not been redirected from the keyboard? How portable is such a > > method, i.e. will it hold up for Linux? To allow for use of > > external terminals, I guess the thing wanted is to detect that > > stdin is actually a disk file (or a pipe) as opposed to a device. > [snip] > > Take a look at isatty: > > info libc alpha isatty That looks promising, except it needs an int file descriptor. After a little research in stdio.h I conclude that "fileno(fp)" is required. So I need to work with "if (isatty(fileno(stdin)))" and that should cover the portability area. Thanks, that did it. I want this for a class of filters that normally shut up, but give help if run with no redirection. -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net) Available for consulting/temporary embedded and systems. USE worldnet address!