I have this strange situation where the read(2) system call is always returning number of bytes read as 0. I know that this happens when the EOF is reached or the bytes to be read is specifed as 0. I am quite sure that none of the above are true in this scenario.
Here is the code snippet which may help in understanding the problem statement.
po=ACE_OS::lseek(file_hand,-(offset+4),SEEK_CUR);
cout<<"po:"<<po<<endl;
cout<<"file_hand: "<<file_hand<<endl;
// Read message number.
if (!(nobr = ACE_OS::read(file_hand,(char*)buffer,1)))
{
cout << "errno " << errno << endl;
cout<<"Failed to read the message number"<<endl;
ERROR("%s", "Failed to read the message number");
ACE_OS::close(file_hand);
return 0;
}
The fd was opened in the below way. file_hand = ACE_OS::open(getFullPathName().c_str(), O_RDONLY,ACE_DEFAULT_OPEN_PERMS);