This is the mail archive of the
mailing list for the Cygwin project.
named pipe (fifo) question
- From: bob 295 <icanprogram at 295 dot ca>
- To: cygwin at cygwin dot com
- Date: Tue, 19 Apr 2011 11:01:55 -0400
- Subject: named pipe (fifo) question
I'm porting a library from Linux to Cygwin and I've encountered a problem with
the behavior of named pipes (fifo's).
In my sequence a pair of fifos are opened by each end of the conversation.
One is opened as WRONLY, the other as RDWR. Some documentation seems to
frown on RDWR pipes. We found that this allows us to trap certain errors
when processes on other ends of the pipe vanish.
The message exchange sequence is then:
For the sender
i) open the WRONLY pipe to receiver
ii) write an integer on the WRONLY pipe
iii) drop into a read on the RDWR pipe (which blocks in Linux)
For the receiver
i) drop into read on the RDWR pipe (which blocks in Linux)
ii) process the message
iii) open the WRONLY end of pipe for response
iv) write an integer onto the WRONLY pipe back to sender
v) close the WRONLY end of pipe
The sender leaves the WRONLY pipe open in case another message will be sent.
It only closes the file descriptor upon process exit. The receiver opens,
writes and closes its WRONLY end on each pass. In Linux this sequence works
just fine and has been working in all versions for at least 10 years now.
However, on Cygwin it would appear that after the first time the receiver
closes the WRONLY end of the sender's pipe, the sender's next read comes
back with a 0 (eof) repeatedly without ever blocking.
Is this the intended POSIX behavior? Is the problem the RDWR open?
Thanks in advance for your help.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple