From nobody@FreeBSD.ORG Mon Sep  6 00:18:01 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 397DE1520F; Mon,  6 Sep 1999 00:18:01 -0700 (PDT)
Message-Id: <19990906071801.397DE1520F@hub.freebsd.org>
Date: Mon,  6 Sep 1999 00:18:01 -0700 (PDT)
From: tarkhil@asteroid.svib.ru
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: Problems with FIFO and select
X-Send-Pr-Version: www-1.0

>Number:         13593
>Category:       kern
>Synopsis:       Problems with FIFO and select
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep  6 00:20:01 PDT 1999
>Closed-Date:    Fri Jul 20 17:54:37 PDT 2001
>Last-Modified:  Fri Jul 20 17:55:23 PDT 2001
>Originator:     Alex Povolotsky
>Release:        3.2-STABLE
>Organization:
>Environment:
FreeBSD shuttle.svib.ru 3.0-19990619-STABLE FreeBSD 3.0-19990619-STABLE #0: Thu Jun 24 21:26:37 MSD 1999     root@shuttle.svib.ru:/mnt/usr/src/sys/compile/SHUTTLE  i386

>Description:
Attempt to open FIFO file with O_WRONLY|O_NONBLOCK results in Device not configured error.

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.

>How-To-Repeat:
#include <stdio.h>
#include <fcntl.h>

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);
}

>Fix:


>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: freebsd-gnats-submit@FreeBSD.ORG, tarkhil@asteroid.svib.ru
Cc:  
Subject: Re: kern/13593: Problems with FIFO and select
Date: Mon, 6 Sep 1999 17:46:06 +1000

 >>Description:
 >Attempt to open FIFO file with O_WRONLY|O_NONBLOCK results in Device
 >not configured error.
 
 This is because there is no reader when the FIFO is opened for writing
 (O_WRONLY opens of FIFOs normally block waiting for a reader, but
 O_NONBLOCK gives an error instead).
 
 >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.
 
 This is because O_RDWR gives both a reader and a writer.
 
 Summary: not a FreeBSD bug.
 
 Bruce
 
State-Changed-From-To: open->closed 
State-Changed-By: mike 
State-Changed-When: Fri Jul 20 17:54:37 PDT 2001 
State-Changed-Why:  

This is expected behaviour.  See bde's comments for details. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=13593 
>Unformatted:
