lmkd: handle missing process' information case
When we get nothing from /proc/<PID>/status and /proc/<PID>/cmdline, we should return NULL or False because this usually indicates the process has already terminated. We should avoid attempting to kill a non-existent process, as it's an unnecessary waste of kill timeout. Bug: 331612600 Test: give memory pressure to trigger LMKD Change-Id: I468ff25012f9bb6fc842a7fad268ebcad0de4690 Signed-off-by: Martin Liu <liumartin@google.com>
This commit is contained in:
parent
ee6412ebf0
commit
d10742025b
4
lmkd.cpp
4
lmkd.cpp
|
|
@ -1050,7 +1050,7 @@ static bool read_proc_status(int pid, char *buf, size_t buf_sz) {
|
||||||
|
|
||||||
size = read_all(fd, buf, buf_sz - 1);
|
size = read_all(fd, buf, buf_sz - 1);
|
||||||
close(fd);
|
close(fd);
|
||||||
if (size < 0) {
|
if (size <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
buf[size] = 0;
|
buf[size] = 0;
|
||||||
|
|
@ -1118,7 +1118,7 @@ static char *proc_get_name(int pid, char *buf, size_t buf_size) {
|
||||||
}
|
}
|
||||||
ret = read_all(fd, buf, buf_size - 1);
|
ret = read_all(fd, buf, buf_size - 1);
|
||||||
close(fd);
|
close(fd);
|
||||||
if (ret < 0) {
|
if (ret <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
buf[ret] = '\0';
|
buf[ret] = '\0';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue