read()调用总是返回0作为读取的字节数

时间:2012-11-14 08:25:43

标签: c++ linux ace

我遇到这种奇怪的情况,其中read(2)系统调用总是返回读取为0的字节数。 我知道当达到EOF或者要读取的字节被指定为0时会发生这种情况。 我很确定在这种情况下,上述情况都不正确。

以下是可能有助于理解问题陈述的代码段。

    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;
    }

fd以下面的方式打开了。   file_hand = ACE_OS :: open(getFullPathName()。c_str(),O_RDONLY,ACE_DEFAULT_OPEN_PERMS);

0 个答案:

没有答案
相关问题