|
a/src/execmd.cpp |
|
b/src/execmd.cpp |
|
... |
|
... |
653 |
}
|
653 |
}
|
654 |
} while (cnt > 0 && ntot < cnt);
|
654 |
} while (cnt > 0 && ntot < cnt);
|
655 |
return ntot;
|
655 |
return ntot;
|
656 |
}
|
656 |
}
|
657 |
|
657 |
|
658 |
int ExecCmd::getline(std::string& data)
|
658 |
int ExecCmd::getline(std::string& data, int timeo)
|
659 |
{
|
659 |
{
|
660 |
NetconCli *con = dynamic_cast<NetconCli *>(m_fromcmd.get());
|
660 |
NetconCli *con = dynamic_cast<NetconCli *>(m_fromcmd.get());
|
661 |
if (con == 0) {
|
661 |
if (con == 0) {
|
662 |
LOGERR(("ExecCmd::receive: inpipe is closed\n"));
|
662 |
LOGERR(("ExecCmd::receive: inpipe is closed\n"));
|
663 |
return -1;
|
663 |
return -1;
|
664 |
}
|
664 |
}
|
665 |
const int BS = 1024;
|
665 |
const int BS = 1024;
|
666 |
char buf[BS];
|
666 |
char buf[BS];
|
667 |
int n = con->getline(buf, BS);
|
667 |
int n = con->getline(buf, BS, timeo);
|
668 |
if (n < 0) {
|
668 |
if (n < 0) {
|
669 |
LOGERR(("ExecCmd::getline: error\n"));
|
669 |
LOGERR(("ExecCmd::getline: error\n"));
|
670 |
} else if (n > 0) {
|
670 |
} else if (n > 0) {
|
671 |
data.append(buf, n);
|
671 |
data.append(buf, n);
|
672 |
} else {
|
672 |
} else {
|