Bug 13593

Summary: Problems with FIFO and select
Product: Base System Reporter: tarkhil <tarkhil>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.2-STABLE   
Hardware: Any   
OS: Any   

Description tarkhil 1999-09-06 08:20:01 UTC
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);
}
Comment 1 Bruce Evans 1999-09-06 08:46:06 UTC
>>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
Comment 2 Mike Barcroft freebsd_committer freebsd_triage 2001-07-21 01:54:37 UTC
State Changed
From-To: open->closed


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