mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-03 07:01:53 +00:00
Prevent file descriptor from unclosed
This commit is contained in:
@@ -51,11 +51,12 @@ static int parse_ppid(int pid) {
|
||||
char path[32];
|
||||
int ppid;
|
||||
sprintf(path, "/proc/%d/stat", pid);
|
||||
FILE *stat = fopen(path, "r");
|
||||
FILE *stat = xfopen(path, "re");
|
||||
if (stat == nullptr)
|
||||
return -1;
|
||||
/* PID COMM STATE PPID ..... */
|
||||
fscanf(stat, "%*d %*s %*c %d", &ppid);
|
||||
fclose(stat);
|
||||
return ppid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user