summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2014-10-07 14:23:46 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-10-07 14:23:46 +0000
commita083c8578a8cfa44b50e6d1159b83182aba63bcb (patch)
treec5589572e8c8426c1ae9ff4ce38acabccce4ca0a
parent09dc063319d017625fbde0fd380ed677b680415e (diff)
parentf48ea7c8dcfbf2220ececccb1f4fb2f42df9048c (diff)
downloadsystem_core-a083c8578a8cfa44b50e6d1159b83182aba63bcb.zip
system_core-a083c8578a8cfa44b50e6d1159b83182aba63bcb.tar.gz
system_core-a083c8578a8cfa44b50e6d1159b83182aba63bcb.tar.bz2
Merge changes I7d0b85b5,I74796043
* changes: logd: LogStatistics leak logd: kill(0,0) issue
-rw-r--r--logd/LogStatistics.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index baf15fe..6f3a088 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -54,6 +54,9 @@ bool PidStatistics::pidGone() {
if (mGone || (pid == gone)) {
return true;
}
+ if (pid == 0) {
+ return false;
+ }
if (kill(pid, 0) && (errno != EPERM)) {
mGone = true;
return true;
@@ -92,7 +95,9 @@ void PidStatistics::addTotal(size_t size, size_t element) {
// which debuggerd prints as a process is crashing.
char *PidStatistics::pidToName(pid_t pid) {
char *retval = NULL;
- if (pid != gone) {
+ if (pid == 0) { // special case from auditd for kernel
+ retval = strdup("logd.auditd");
+ } else if (pid != gone) {
char buffer[512];
snprintf(buffer, sizeof(buffer), "/proc/%u/cmdline", pid);
int fd = open(buffer, O_RDONLY);
@@ -302,6 +307,10 @@ void LidStatistics::add(unsigned short size, uid_t uid, pid_t pid) {
}
void LidStatistics::subtract(unsigned short size, uid_t uid, pid_t pid) {
+ if (uid == (uid_t) -1) { // init
+ uid = (uid_t) AID_ROOT;
+ }
+
UidStatisticsCollection::iterator it;
for (it = begin(); it != end(); ++it) {
UidStatistics *u = *it;