Xref: utzoo comp.unix.questions:31693 comp.unix.programmer:1911 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!caen!news.cs.indiana.edu!arizona.edu!ace!jjr From: jjr@ace.ece.arizona.edu (Jeffrey J. Rodriguez) Newsgroups: comp.unix.questions,comp.unix.programmer Subject: How do I tell if STDIN is a PIPE? Message-ID: <1991May26.172328.713@arizona.edu> Date: 27 May 91 00:23:27 GMT Sender: rodriguez@ece.arizona.edu Followup-To: rodriguez@ece.arizona.edu,comp.unix.questions,comp.unix.programmer Distribution: world,local Organization: Dept. of ECE, Univ. of Arizona Lines: 13 Nntp-Posting-Host: ace.ece.arizona.edu 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. If stdin is coming from a pipe, then what is the best way to do a seek? If the input data is not ASCII, then a loop of getchar() won't work. Therefore, it seems like a loop of fread (one byte at a time) would be required. Please let me know if there's a better way to handle this. Jeff rodriguez@ece.arizona.edu