From owner-freebsd-stable Mon Sep 6 8:12:33 1999 Delivered-To: freebsd-stable@freebsd.org Received: from bingnet2.cc.binghamton.edu (bingnet2.cc.binghamton.edu [128.226.1.18]) by hub.freebsd.org (Postfix) with ESMTP id 24E4B15A6E; Mon, 6 Sep 1999 08:11:49 -0700 (PDT) (envelope-from zzhang@cs.binghamton.edu) Received: from sol.cs.binghamton.edu (cs1-gw.cs.binghamton.edu [128.226.171.72]) by bingnet2.cc.binghamton.edu (8.9.3/8.9.3) with SMTP id LAA06003; Mon, 6 Sep 1999 11:11:38 -0400 (EDT) Date: Mon, 6 Sep 1999 10:57:50 -0400 (EDT) From: Zhihui Zhang To: Alex Povolotsky Cc: stable@FreeBSD.ORG, hackers@FreeBSD.ORG Subject: Re: Problems with FIFO open in non-blocking mode? In-Reply-To: <199909060547.JAA29146@shuttle.svib.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 6 Sep 1999, Alex Povolotsky wrote: > Hello! > > The following program > > #include > #include > > main() { > int control; > if ((control = open("STATUS",O_WRONLY|O_NONBLOCK))<0) { > perror("Could not open STATUS "); > exit(1); > } > printf("STATUS ready\n"); > close(control); > return(0); > } > > fails to run (STATUS is pre-created FIFO file) with error "Device not > configured", which seems kinda odd for me. > > However, when FIFO is opened with O_RDWR and O_NONBLOCK, every attempt > to select(2) its handler for writing doesn't wait until someone opens > FIFO for reading, but instead FIFO is ready to write at every select. > > Is it a bug or a feature? > I answered a similar question some time ago. You can search the mailing list archive for this. Basically, you need to read the "Advanced Unix Programming Environment" by Stevens. I can not remember every details right now. The "device not configured" error is expected. -Zhihui To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message