Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: Does O_NDELAY shred read(2)? Keywords: O_NDELAY, read, pipes Message-ID: <1989Nov11.025551.5020@virtech.uucp> Date: 11 Nov 89 02:55:51 GMT References: <20764@ut-emx.UUCP> Organization: Virtual Technologies Inc. Lines: 22 In article <20764@ut-emx.UUCP>, jon@walt.cc.utexas.edu (Jon Boede) writes: > If a write(fd,buf,X) is made, will a read(fd2,buf2,X) == X? In other words, I > know that the write will be atomic... will the read also be? Is there a Writes to a pipe are not atomic. They are dependent upon the size of the buffer used by the kernel in transferring the data. And there is an upper limmit on the amount of unread data in the pipe buffer so the write will pause while the data is read. Whether or not your example will work depends upon the smallness of X, the ability of the writing process to call the write (does it have lots of data ready to transfer), the ability of the reading process to read the data (how much time does it spend processing the data), and, of course, it's all implementation dependent. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+