Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cs
ds
procfs
Commits
ff99b1a6
Commit
ff99b1a6
authored
Jun 01, 2021
by
Alessandro Abrami
Browse files
Modified match string versus cmdline
parent
d88ffcfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Procfs.cpp
View file @
ff99b1a6
...
@@ -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
(),
' '
,
'_'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment