How do I tell if STDIN is a PIPE?

Rick Poleshuck rick at ulticorp.UUCP
Thu Jun 6 22:38:32 AEST 1991


In article <23190 at shlump.lkg.dec.com> lan_csse at netrix.nac.dec.com (CSSE LAN Test Account) writes:
>In article <653 at eskimo.celestial.com> nanook at eskimo.celestial.com (Robert Dinse) writes:
>>In article <1991May30.101153.27842 at thunder.mcrcim.mcgill.edu>, mouse at thunder.mcrcim.mcgill.edu (der Mouse) writes:
>>> In article <1991May26.172328.713 at arizona.edu>, jjr at 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



More information about the Comp.unix.questions mailing list