| Summary: | Problems with FIFO and select | ||
|---|---|---|---|
| Product: | Base System | Reporter: | tarkhil <tarkhil> |
| Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 3.2-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
>>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 This is expected behaviour. See bde's comments for details. |
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); }