Commit 552f4c69 authored by Teng Qin's avatar Teng Qin

Don't refresh already gone PIDs

Currently we check if `ProcSyms` needs refresh for every symboling call.
However if the `ProcSyms` was loaded, but the Process terminated later,
we will see it as a "need refresh" and effectively clear the symbol
table and not able to resovle anything anymore.

This commit changes so that we only refresh when the PID still exists
(but differnt from what loaded).
parent 7efd2dc8
......@@ -33,6 +33,11 @@ ino_t ProcStat::getinode_() {
return (!stat(procfs_.c_str(), &s)) ? s.st_ino : -1;
}
bool ProcStat::is_stale() {
ino_t cur_inode = getinode_();
return (cur_inode > 0) && (cur_inode != inode_);
}
ProcStat::ProcStat(int pid)
: procfs_(tfm::format("/proc/%d/exe", pid)), inode_(getinode_()) {}
......
......@@ -30,7 +30,7 @@ class ProcStat {
public:
ProcStat(int pid);
bool is_stale() { return inode_ != getinode_(); }
bool is_stale();
void reset() { inode_ = getinode_(); }
};
......
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