How do I tell if STDIN is a PIPE?

Dave Eisen dkeisen at leland.Stanford.EDU
Mon May 27 12:27:27 AEST 1991


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?
>There must be some system call I can use from a C program.
>My problem is that lseek & fseek won't work with a pipe.
>Therefore, I need to check stdin to see if it is coming from a pipe.

As usual, the best way to see if an operation *would* succeed if you were
to try it is to just go ahead and try it and see if it *did* succeed. If
you seek and it fails and errno is ESPIPE, you know that stdin is 
a pipe.




-- 
Dave Eisen                           dkeisen at leland.Stanford.EDU
1101 San Antonio Road, Suite 102     (Gang-of-Four is being taken off the net)
Mountain View, CA 94043
(415) 967-5644



More information about the Comp.unix.questions mailing list