Prevent file descriptor from unclosed
This commit is contained in:
parent
762b678d24
commit
ec4723096f
@ -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;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ int deleteprop(const char *name, bool persist) {
|
||||
int load_prop_file(const char *filename, const bool trigger) {
|
||||
if (init_resetprop()) return -1;
|
||||
LOGD("resetprop: Load prop file [%s]\n", filename);
|
||||
FILE *fp = fopen(filename, "r");
|
||||
FILE *fp = xfopen(filename, "re");
|
||||
if (fp == nullptr) {
|
||||
LOGE("Cannot open [%s]\n", filename);
|
||||
return 1;
|
||||
|
@ -395,7 +395,7 @@ int file_to_vector(const char *filename, Vector<CharArray> &arr) {
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
|
||||
FILE *fp = xfopen(filename, "r");
|
||||
FILE *fp = xfopen(filename, "re");
|
||||
if (fp == nullptr)
|
||||
return 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user