when opening a FIFO for reading+writing, and blocking - how to tell if other side opened for reading or writing?
0
votes
2
answers
44
views
If I open a fifo for reading+writing in blocking mode:
fd = open("foo", "O_RDWR");
Then it blocks until someone on the other end opens it for either reading or writing. But how do I know which?
if(???) {
read(fd, .......);
} else {
write(fd, ......);
}
close(fd);
(I need that close, because if I am writing I need to send an EOF to the other end. And any writer will send a single line through and close, so I also need to close if I read.)
What do I put instead of the ??? to figure out what the other end did?
Is non-blocking and
select()
my only option? Is there a way to inspect fd
and see if it's ready for reading or writing?
Asked by Ariel
(117 rep)
May 30, 2025, 06:30 PM
Last activity: May 31, 2025, 06:15 AM
Last activity: May 31, 2025, 06:15 AM