[comp.unix.questions] How to find out if stdout is piped?

phd_ivo@gsbacd.uchicago.edu (02/14/90)

**************************************************

In Mach (a BSD 4.3 clone), is there an easy way to
find out if stdout is hooked to a pipe, or redirected
into a file?

/ivo welch	ivo@next.agsm.ucla.edu

echarne@orion.oac.uci.edu (Eli B. Charne) (02/14/90)

phd_ivo@gsbacd.uchicago.edu writes:

>In Mach (a BSD 4.3 clone), is there an easy way to
>find out if stdout is hooked to a pipe, or redirected
>into a file?

  Yes.

  Use the library routine isatty()

     isatty(filedes)

     Isatty returns 1 if filedes is associated with a terminal
     device, 0 otherwise.

						     -Eli

-- 
--------
Eli B. Charne              INTERNET: echarne@ORION.OAC.UCI.EDU
			     BITNET: echarne@UCI.BITNET

gwyn@smoke.BRL.MIL (Doug Gwyn) (02/14/90)

In article <7638@tank.uchicago.edu> phd_ivo@gsbacd.uchicago.edu writes:
>find out if stdout is hooked to a pipe, or redirected into a file?

use fstat(1,...)