Commit 4ab73947 authored by Alessio Igor Bogani's avatar Alessio Igor Bogani
Browse files

Merge branch 'branch_aa_01' into 'master'

Modified match string versus cmdline

See merge request !1
parents d88ffcfe ff99b1a6
......@@ -84,6 +84,20 @@ int filter(const struct dirent *dir)
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
//--------------------------------------------------------
......@@ -711,7 +725,7 @@ void* ProcfsWorker::run_undetached(void *ptr)
string attr_name;
vector<ProcessData>::iterator it, it_old;
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];
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