Xref: utzoo comp.unix.questions:31695 comp.unix.programmer:1912 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!agate!stanford.edu!leland.Stanford.EDU!dkeisen From: dkeisen@leland.Stanford.EDU (Dave Eisen) Newsgroups: comp.unix.questions,comp.unix.programmer Subject: Re: How do I tell if STDIN is a PIPE? Message-ID: <1991May27.022727.9860@leland.Stanford.EDU> Date: 27 May 91 02:27:27 GMT Article-I.D.: leland.1991May27.022727.9860 References: <1991May26.172328.713@arizona.edu> Organization: Sequoia Peripherals, Inc. Lines: 19 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? >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@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