From owner-freebsd-hackers Tue Feb 13 09:58:40 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id JAA26426 for hackers-outgoing; Tue, 13 Feb 1996 09:58:40 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id JAA26421 for ; Tue, 13 Feb 1996 09:58:38 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id KAA23393; Tue, 13 Feb 1996 10:53:41 -0700 From: Terry Lambert Message-Id: <199602131753.KAA23393@phaeton.artisoft.com> Subject: Re: device driver ioctl for nonblocking IO? To: bde@zeta.org.au (Bruce Evans) Date: Tue, 13 Feb 1996 10:53:41 -0700 (MST) Cc: msmith@atrad.adelaide.edu.au, hackers@FreeBSD.ORG In-Reply-To: <199602130909.UAA19799@godzilla.zeta.org.au> from "Bruce Evans" at Feb 13, 96 08:09:43 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG Precedence: bulk > >> I've got a really stupid one here... > >... > >> If I open an fd on the device and fcntl(fd, F_SETFL, O_NONBLOCK), I get > >> a mystery ioctl sent to my device. > > >Argh. FIONBIO. Not enough coffee. Sorry. > > FIONBIO should be ignored unless you want to handle the races that can > result when a process changes the flag while another process is blocked > in an i/o. The O_NONBLOCK flag (aka the O_NDELAY flag) (aka the FNDELAY > flag) is better aka the FNONBLOCK flag in the kernel. It is stored in > the file descriptor flags and passed to all read and write functions > after converting it to the IO_NDELAY. It is also passed to the open, > ioctl and close functions without conversion. The race is easily handled by blocking the FIONBIO operation on the same semaphore, I think. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.