logd: kill(0,0) issue
- Recognize pid=0 as special case (kernel or pre-init sourced)
and refrain from treating it in the general case.
(cherry pick from commit df5aa61f05
)
Bug: 17526159
Change-Id: I74796043ac34753c6dd10018719ebc0bcd94e012
This commit is contained in:
parent
1e1d71e26c
commit
260f3be312
1 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue