From owner-freebsd-questions Wed Mar 13 03:25:52 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id DAA23806 for questions-outgoing; Wed, 13 Mar 1996 03:25:52 -0800 (PST) Received: from hda.com (hda.com [199.232.40.182]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id DAA23797 for ; Wed, 13 Mar 1996 03:25:47 -0800 (PST) Received: (from dufault@localhost) by hda.com (8.6.11/8.6.9) id FAA24643; Wed, 13 Mar 1996 05:45:43 -0500 From: Peter Dufault Message-Id: <199603131045.FAA24643@hda.com> Subject: Re: non-blocking read ? To: luigi@labinfo.iet.unipi.it (Luigi Rizzo) Date: Wed, 13 Mar 1996 05:45:43 -0500 (EST) Cc: questions@FreeBSD.org In-Reply-To: <199603111814.TAA18793@labinfo.iet.unipi.it> from "Luigi Rizzo" at Mar 11, 96 07:14:37 pm X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-questions@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > > Hi, > is there a simple way to issue a non-blocking read to a regular file ? > > Ideally, I would like a > > nbread(handle, buf, count); > > which would start reading from the disk, and could then notify > the completion of I/O via select(). > > I don't know if fcntl() is enough: you can specify O_NONBLOCK for the > file, but then I have no idea if select() on that descriptor > would return immediately or will wait for at least one/the desired > amound of bytes to be available. If you're interested in portability then the POSIX spec says that O_NONBLOCK behavior on a regular file is unspecified. If you don't mind the extra syscall overhead then you can stat the file and keep track of what was there. I do this in a data logging display package. This should be portable. -- *** March 13, 1996: Our ISP may be GONE. You may never read this. *** *** "hda.com" connectivity is now intermittent to nonexistent *** Peter Dufault Real-Time Machine Control and Simulation HD Associates, Inc. Voice: 508 433 6936 dufault@hda.com Fax: 508 433 5267