How to tell if stdin/stdout is redirected?

Ralf Brown ralf at b.gp.cs.cmu.edu
Thu Mar 29 07:49:25 AEST 1990


In article <807 at tsdiag.ccur.com> jeffs at tsdiag.ccur.com (Jeff Schnell) writes:
}I would like to know if there is a way to tell if stdin/stdout
}is redirected.  I would like it in Turbo C and/or Microsoft C
}and also in unix.

	isatty(fileno(stdin))

works for me under Turbo C (returns nonzero iff stdin points at a character 
device such as CON, PRN, etc) and should work under Unix (since that is where
isatty originated).



-- 
{backbone}!cs.cmu.edu!ralf   ARPA: RALF at CS.CMU.EDU   FIDO: Ralf Brown 1:129/46
BITnet: RALF%CS.CMU.EDU at CMUCCVMA   AT&Tnet: (412)268-3053 (school)   FAX: ask
DISCLAIMER? | _How_to_Prove_It_ by Dana Angluin  3. by vigorous handwaving:
What's that?|   	Works well in a classroom or seminar setting.



More information about the Comp.lang.c mailing list