mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-28 01:28:30 +00:00
Do not try to remove kdeinit: from process name
When we parse /proc/<pid>/* in order to populate the process struct, it isn't necessary to try to remove any instance of "kdeinit: " anymore (IMO). Here is why: * If the user chooses to display full command lines (top_name_verbose = true), then we should show full command lines without stripping useful info. * The new basename entry already has a stripped down command. For example, if the command line is "kdeinit4: kded4 [kdeinit]", then basename is "kded4". * The code does not account for "kdeinit{4,5}: ", resulting in undesired behavior, e.g. "kdeinit4: kded4 [kdeinit]" becomes "kdeinit4:". * The code does not account for NUL separated arguments. * The code opens /proc/<pid>/cmdline a second time, so this commit is a minor optimization. I think it is best to remove this code altogether. If anyone disagrees, please comment or send me some hate mail with reasons why we should keep it. The commit is easy enough to revert. :)
This commit is contained in:
parent
03a5cc5047
commit
8f88961c74
32
src/linux.cc
32
src/linux.cc
@ -2739,38 +2739,6 @@ static void process_parse_stat(struct process *process)
|
||||
if (state[0] == 'R')
|
||||
++ info.run_procs;
|
||||
|
||||
/* remove any "kdeinit: " */
|
||||
if (procname == strstr(procname, "kdeinit")) {
|
||||
snprintf(filename, sizeof(filename), PROCFS_CMDLINE_TEMPLATE,
|
||||
process->pid);
|
||||
|
||||
ps = open(filename, O_RDONLY);
|
||||
if (ps < 0) {
|
||||
/* The process must have finished in the last few jiffies! */
|
||||
return;
|
||||
}
|
||||
|
||||
endl = read(ps, line, BUFFER_LEN - 1);
|
||||
close(ps);
|
||||
if(endl < 0)
|
||||
return;
|
||||
line[endl] = 0;
|
||||
|
||||
/* account for "kdeinit: " */
|
||||
if ((char *) line == strstr(line, "kdeinit: ")) {
|
||||
r = ((char *) line) + 9;
|
||||
} else {
|
||||
r = (char *) line;
|
||||
}
|
||||
|
||||
q = procname;
|
||||
/* stop at space */
|
||||
while (*r && *r != ' ') {
|
||||
*q++ = *r++;
|
||||
}
|
||||
*q = 0;
|
||||
}
|
||||
|
||||
free_and_zero(process->name);
|
||||
free_and_zero(process->basename);
|
||||
process->name = strndup(procname, text_buffer_size.get(*::state));
|
||||
|
Loading…
x
Reference in New Issue
Block a user