Xref: utzoo comp.unix.questions:31902 comp.unix.programmer:1973 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!decprl!decprl!boyd From: boyd@prl.dec.com (Boyd Roberts) Newsgroups: comp.unix.questions,comp.unix.programmer Subject: Re: How do I tell if STDIN is a PIPE? Message-ID: <1991Jun3.150851.21915@prl.dec.com> Date: 3 Jun 91 15:08:51 GMT References: <1991May26.172328.713@arizona.edu> <1991May30.101153.27842@thunder.mcrcim.mcgill.edu> <653@eskimo.celestial.com> <1991Jun3.141144.23620@leland.Stanford.EDU> Sender: news@prl.dec.com (USENET News System) Reply-To: boyd@prl.dec.com (Boyd Roberts) Distribution: world,local Organization: Digital Equipment Corporation - Paris Research Laboratory Lines: 26 In article <1991Jun3.141144.23620@leland.Stanford.EDU>, dkeisen@leland.Stanford.EDU (Dave Eisen) writes: > > >> In article <1991May26.172328.713@arizona.edu>, jjr@ace.ece.arizona.edu (Jeffrey J. Rodriguez) writes: > > > > Try: > > fstat(0, &s); > > if(s.st_mode & S_IFIFO) > > ... > > This doesn't work everywhere, in particular, it doesn't work on the machine I > am posting from. s.st_mode & S_IFREG (which, by the way, is what you should > be testing for) is 0 when stdin is a pipe. This doesn't seem to be consistently > done across Unices. > You don't test for anything that way. This: if ((sb.st_mode & S_IFMT) == S_IFIFO) is the way it's done (unless you have those gory POSIX macros). But, of course they're not `portable'; except to POSIX. Boyd Roberts boyd@prl.dec.com ``When the going gets wierd, the weird turn pro...''