From owner-freebsd-questions Tue Mar 12 08:28:01 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id IAA26626 for questions-outgoing; Tue, 12 Mar 1996 08:28:01 -0800 (PST) Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id IAA26614 for ; Tue, 12 Mar 1996 08:27:56 -0800 (PST) Received: from gemini.sdsp.mc.xerox.com ([13.231.132.20]) by alpha.xerox.com with SMTP id <14433(7)>; Tue, 12 Mar 1996 08:27:15 PST Received: from gnu.mc.xerox.com (gnu.sdsp.mc.xerox.com) by gemini.sdsp.mc.xerox.com (4.1/SMI-4.1) id AA01250; Tue, 12 Mar 96 11:27:17 EST Received: by gnu.mc.xerox.com (4.1/SMI-4.1) id AA07775; Tue, 12 Mar 96 11:27:12 EST Message-Id: <9603121627.AA07775@gnu.mc.xerox.com> X-Mailer: exmh version 1.6.4 10/10/95 To: Michael Smith Cc: luigi@labinfo.iet.unipi.it (Luigi Rizzo), questions@freebsd.org Subject: Re: non-blocking read ? In-Reply-To: Your message of "Mon, 11 Mar 1996 16:06:33 PST." <199603120006.KAA24326@genesis.atrad.adelaide.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 12 Mar 1996 08:27:03 PST From: "Marty Leisner" Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > Luigi Rizzo stands accused of saying: > > 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(). > > Use async I/O and handle SIGIO like everybody else 8) > > > 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. > > Select may well behave strangely on regular files; at least I'd expect it > to return immediately unless there's an EOF or error condition. > Reads to regular files are non-blocking by default -- you either read the next block or return EOF...note, they may take "time", but it isn't like a socket or a pipe where you'd wait until something happens... -- marty leisner@sdsp.mc.xerox.com Member of the League for Programming Freedom