Commit 45fb3f25 authored by Carla Guillen's avatar Carla Guillen

bigfix: adding pclose!

parent b9df90b9
......@@ -59,9 +59,10 @@ GpfsmonSensorGroup::~GpfsmonSensorGroup() {
void GpfsmonSensorGroup::read() {
ureading_t reading;
reading.timestamp = getTimestamp();
FILE * pf = nullptr;
try {
std::string toparse;
FILE * pf = popen(_cmd_io.c_str(), "r");
pf = popen(_cmd_io.c_str(), "r");
if (pf != nullptr) {
char buf[BUFFER_SIZE];
while (fgets(buf, BUFFER_SIZE, pf) != nullptr) {
......@@ -80,12 +81,17 @@ void GpfsmonSensorGroup::read() {
createTempFile();
}
}
pclose(pf);
pf = nullptr;
} else {
LOG(error) << "Sensorgroup " << _groupName << " popen failed: " << strerror(errno);
}
} catch (const std::exception &e) {
LOG(error) << "Sensorgroup " << _groupName << " could not read value: " << e.what();
}
if(pf != nullptr){
pclose(pf);
}
}
void GpfsmonSensorGroup::createTempFile() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment