Path: utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!voder!kontron!optilink!cramer From: cramer@optilink.UUCP (Clayton Cramer) Newsgroups: comp.sys.ibm.pc Subject: Re: How to determine stdin/out redirection Message-ID: <503@optilink.UUCP> Date: 27 Sep 88 16:27:40 GMT References: <9465@cup.portal.com> Organization: Optilink Corporation, Petaluma, CA Lines: 15 In article <9465@cup.portal.com>, Steve_R_Calwas@cup.portal.com writes: > > Is there a way for an application program to determine whether or not its > standard input and/or standard output are being redirected? > > Steve Calwas src@cup.portal.com It's not 100% foolproof, but use the isatty(fileno(stdin)) function to determine if stdin is talking to a character device -- this is a pretty trustworthy method. If true, you are almost certainly talking to the console, and stdin is not redirected. -- Clayton E. Cramer ..!ames!pyramid!kontron!optilin!cramer