|
-
May 10th, 2012, 04:40 PM
#1
[RESOLVED] FIFO reads endlessly after I close it on the producer side.
Hello,
Right after I close FIFO on the producer side, the app on the consumer side gets into an endless loop. select() returns that FIFO is ready to read. Below is the excerpt from the consumer code. The FIFO is opened "blocking" on both ends.
Could someone help me. Thank you!
Code:
FifoClass fifo_r = FifoClass("/tmp/FIFO_READ");
int fdr = fifo_r.OpenR(); // this->fd = open(name.c_str(), O_RDONLY , 0);
for(int i=0; ;i++)
{
FD_ZERO(&rset);
FD_SET(fdr, &rset);
maxfdp = max(fdr, 0)+1;
select(maxfdp, &rset, NULL, NULL, NULL);
// Read from FIFO.
if (FD_ISSET(fdr, &rset))
{
ret = fifo_r.Read(&message);
message += message + " *** " + to_string(i) + ".";
cout << message << endl << flush;
}
} // for()
-
May 10th, 2012, 05:01 PM
#2
Re: FIFO reads endlessly after I close it on the producer side.
Any function that returns an error code needs to be checked for success/failure. See if that helps things any.
gg
-
May 11th, 2012, 09:56 PM
#3
Re: FIFO reads endlessly after I close it on the producer side.
Right, there was an error EEXIST when I was creating FIFO b/c that FIFO already existed.
Thanks again for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|