summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2018-09-23 21:14:54 +0300
committerGitHub <noreply@github.com>2018-09-23 21:14:54 +0300
commitfc1008b7cc6d8fe6a5252bf0e7444b94d861ff81 (patch)
tree7255460bd09e9209a68169da26f8c33bd619b007 /src
parent1c7fb92255179796f50aff9400890ef8c642dfdc (diff)
apps.plugin fixes (#4267)
Diffstat (limited to 'src')
-rw-r--r--src/apps_plugin.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/apps_plugin.c b/src/apps_plugin.c
index b6589e718e..6525fdeb3e 100644
--- a/src/apps_plugin.c
+++ b/src/apps_plugin.c
@@ -895,9 +895,11 @@ static inline int read_proc_pid_cmdline(struct pid_stat *p) {
#endif
cmdline[bytes] = '\0';
- for(i = 0; i < bytes ; i++)
+ for(i = 0; i < bytes ; i++) {
if(unlikely(!cmdline[i])) cmdline[i] = ' ';
+ }
+ if(p->cmdline) freez(p->cmdline);
p->cmdline = strdupz(cmdline);
debug_log("Read file '%s' contents: %s", p->cmdline_filename, p->cmdline);
@@ -906,6 +908,7 @@ static inline int read_proc_pid_cmdline(struct pid_stat *p) {
cleanup:
// copy the command to the command line
+ if(p->cmdline) freez(p->cmdline);
p->cmdline = strdupz(p->comm);
return 0;
}
@@ -1808,10 +1811,10 @@ static inline int read_pid_file_descriptors(struct pid_stat *p, void *ptr) {
p->fds_size = (size_t)fdid + MAX_SPARE_FDS;
}
- if(unlikely(p->fds[fdid].fd != 0 && de->d_ino != p->fds[fdid].inode)) {
+ if(unlikely(p->fds[fdid].fd < 0 && de->d_ino != p->fds[fdid].inode)) {
// inodes do not match, clear the previous entry
inodes_changed_counter++;
- file_descriptor_not_used(p->fds[fdid].fd);
+ file_descriptor_not_used(-p->fds[fdid].fd);
clear_pid_fd(&p->fds[fdid]);
}
@@ -1836,8 +1839,8 @@ static inline int read_pid_file_descriptors(struct pid_stat *p, void *ptr) {
if(debug_enabled || (p->target && p->target->debug_enabled))
error("Cannot read link %s", p->fds[fdid].filename);
- if(unlikely(p->fds[fdid].fd)) {
- file_descriptor_not_used(p->fds[fdid].fd);
+ if(unlikely(p->fds[fdid].fd < 0)) {
+ file_descriptor_not_used(-p->fds[fdid].fd);
clear_pid_fd(&p->fds[fdid]);
}
@@ -1848,10 +1851,10 @@ static inline int read_pid_file_descriptors(struct pid_stat *p, void *ptr) {
uint32_t link_hash = simple_hash(linkname);
- if(unlikely(p->fds[fdid].fd && p->fds[fdid].link_hash != link_hash)) {
+ if(unlikely(p->fds[fdid].fd < 0 && p->fds[fdid].link_hash != link_hash)) {
// the link changed
links_changed_counter++;
- file_descriptor_not_used(p->fds[fdid].fd);
+ file_descriptor_not_used(-p->fds[fdid].fd);
clear_pid_fd(&p->fds[fdid]);
}