Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!midway!clout!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.questions Subject: Re: A question about read() system call!! Message-ID: <1991May22.215820.9566@chinet.chi.il.us> Date: 22 May 91 21:58:20 GMT References: <28398698.26968@maccs.dcss.mcmaster.ca> Organization: Chinet - Chicago Public Access UNIX Lines: 17 In article <28398698.26968@maccs.dcss.mcmaster.ca> ashraf@maccs.dcss.mcmaster.ca (Ashraf Mahmoud) writes: > 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? If you really want to do it that way you can use fcntl() to set the O_NDELAY flag. However, unless you are very careful to limit the speed at which you loop through the read() requests you are likely to swamp the machine with hundreds of system calls per second. Sometimes there are better ways to design a program - sometimes a 1 second sleep in the loop will keep everybody happy. Les Mikesell les@chinet.chi.il.us