Commit ff99b1a6 authored by Alessandro Abrami's avatar Alessandro Abrami
Browse files

Modified match string versus cmdline

parent d88ffcfe
...@@ -84,6 +84,20 @@ int filter(const struct dirent *dir) ...@@ -84,6 +84,20 @@ int filter(const struct dirent *dir)
return isdigit(dir->d_name[0]); return isdigit(dir->d_name[0]);
} }
const std::string WHITESPACE = " \n\r\t\f\v";
static std::string ltrim(const std::string &s)
{
size_t start = s.find_first_not_of(WHITESPACE);
return (start == std::string::npos) ? "" : s.substr(start);
}
static std::string rtrim(const std::string &s)
{
size_t end = s.find_last_not_of(WHITESPACE);
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
}
/*----- PROTECTED REGION END -----*/ // Procfs::namespace_starting /*----- PROTECTED REGION END -----*/ // Procfs::namespace_starting
//-------------------------------------------------------- //--------------------------------------------------------
...@@ -711,7 +725,7 @@ void* ProcfsWorker::run_undetached(void *ptr) ...@@ -711,7 +725,7 @@ void* ProcfsWorker::run_undetached(void *ptr)
string attr_name; string attr_name;
vector<ProcessData>::iterator it, it_old; vector<ProcessData>::iterator it, it_old;
for (it = device->proc_table.begin(); it != device->proc_table.end(); ++it) { for (it = device->proc_table.begin(); it != device->proc_table.end(); ++it) {
if (strstr((it->cmdline).c_str(), device->matchStrings[exp].c_str())) { if ( 0 == strcasecmp(basename(rtrim(it->cmdline).c_str()), basename(rtrim(device->matchStrings[exp]).c_str())) ) {
attr_name = device->matchStrings[exp]; attr_name = device->matchStrings[exp];
replace(attr_name.begin(), attr_name.end(), ' ', '_'); replace(attr_name.begin(), attr_name.end(), ' ', '_');
......
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