lmkd: Fix killed process name reporting
Fix termination of killed process name in proc_get_name function. While at it also fix the coding style in the function. Test: lmkd_unit_test Bug: 141780598 Change-Id: I3f99b3e37b9a9d0750ece94f08f0b50ac839dacb Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
2c392b6d0a
commit
9e359dbe61
1 changed files with 6 additions and 2 deletions
|
|
@ -1321,8 +1321,9 @@ static char *proc_get_name(int pid) {
|
|||
/* gid containing AID_READPROC required */
|
||||
snprintf(path, PATH_MAX, "/proc/%d/cmdline", pid);
|
||||
fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1)
|
||||
if (fd == -1) {
|
||||
return NULL;
|
||||
}
|
||||
ret = read_all(fd, line, sizeof(line) - 1);
|
||||
close(fd);
|
||||
if (ret < 0) {
|
||||
|
|
@ -1330,8 +1331,11 @@ static char *proc_get_name(int pid) {
|
|||
}
|
||||
|
||||
cp = strchr(line, ' ');
|
||||
if (cp)
|
||||
if (cp) {
|
||||
*cp = '\0';
|
||||
} else {
|
||||
line[ret] = '\0';
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue