Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!sdd.hp.com!hplabs!hpcc05!hpsciz!dougy From: dougy@hpsciz.sc.hp.com (Doug Yip) Newsgroups: comp.unix.questions Subject: Re: A question about read() system call!! Message-ID: <690002@hpsciz.sc.hp.com> Date: 22 May 91 21:52:13 GMT References: <28398698.26968@maccs.dcss.mcmaster.ca> Organization: Hewlett-Packard, Santa Clara, CA Lines: 22 > I wonder if I can get help regarding the unix system call "read()". >When a program executes this system call to read from an empty pipeline, >shouldn't it return zero ( nothing is read ) and passes control to the next >statement? I think it remains stuck waiting for something to be put it the >pipeline. How can I overcome this behaviour? That is making it pass control >to next statement even if pipeline is empty. I would appreciate responses. There are two options to solve this problem: If the file is already open, you can do a fcntl(fd,F_SETFL,O_NDELAY). If the file is not open yet, you can specify the O_NDELAY option when you open the file. You need to include the following files for the options to work according to my manual: #include #include #include