Problem with "write" function in linux
Posted
by Dumitru Catalin
on Stack Overflow
See other posts from Stack Overflow
or by Dumitru Catalin
Published on 2010-06-02T09:28:59Z
Indexed on
2010/06/02
9:34 UTC
Read the original article
Hit count: 253
I am trying to write 2 server/client programs under Linux, in which they communicate through named pipes. The problem is that sometimes when I try to write from the server into a pipe that doesn't exist anymore (the client has stopped), I get a "Resource temporarily unavailable" error and the server stops completely.
I understand that this is caused by using a O_NONBLOCK parameter when opening the fifo chanel, indicating the point where the program would usually wait until it could write again in the file, but is there a way to stop this behavior, and not halt the entire program if a problem occurs (shouldn't the write command return -1 ad the program continue normally)?
And another strange thing is that this error only occurs when running the programs outside the ide (eclipse). If I run both programs inside eclipse, on error the write function just returns -1 and the programs continues normally.
© Stack Overflow or respective owner