Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!ddtisvr.ddtg.com!pechner From: pechner@ddtg.com (Michael Pechner) Newsgroups: comp.unix.questions Subject: Re: How do I tell if STDIN is a PIPE? Message-ID: <1991Jun7.214926.20486@ddtg.com> Date: 7 Jun 91 21:49:26 GMT References: <653@eskimo.celestial.com> <23190@shlump.lkg.dec.com> <494@ulticorp.UUCP> Sender: news@ddtg.com Distribution: world,local Organization: DuPont Design Technologies Group Lines: 26 In article <494@ulticorp.UUCP> rick@ulticorp.UUCP (Rick Poleshuck) writes: >In article <23190@shlump.lkg.dec.com> lan_csse@netrix.nac.dec.com (CSSE LAN Test Account) writes: >>In article <653@eskimo.celestial.com> nanook@eskimo.celestial.com (Robert Dinse) writes: >>>In article <1991May30.101153.27842@thunder.mcrcim.mcgill.edu>, mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes: >>>> In article <1991May26.172328.713@arizona.edu>, jjr@ace.ece.arizona.edu (Jeffrey J. Rodriguez) writes: >>>> >>>> > How do I tell whether stdin is coming from a pipe? >>>> > >/* this looks real stupid but is quite portable */ >if ( lseek( 0, 0l, 0 ) < 0 && errno == ESPIPE ) > puts( "stdin is from a pipe" ); > >-- > | Email - !uunet!ulticorp!ultixrs!rick >Rick Poleshuck | Voice - (201) 887-9222 Ext. 755 > | Mail - The Ultimate Corporation, East Hanover, NJ 07936 This error is not just for pipes. It is for non_seekable devices in general. -- pechner@ddtg.com (Michael Pechner) | Pizza Probably The Worlds Most DuPont Design Technologies Group | Perfect Food. Santa Clara, Ca | Carbo, Meat, Dairy, And Veggie | All Food Groups In One.