Make sure SDL file descriptors don't leak into child processes

This commit is contained in:
Sam Lantinga
2021-09-08 14:47:40 -07:00
parent 3ed8ba7d33
commit bf97c5a22f
15 changed files with 24 additions and 24 deletions

View File

@@ -51,7 +51,7 @@ open_power_file(const char *base, const char *node, const char *key)
}
snprintf(path, pathlen, "%s/%s/%s", base, node, key);
return open(path, O_RDONLY);
return open(path, O_RDONLY | O_CLOEXEC);
}
@@ -330,7 +330,7 @@ SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state,
int battery_flag = 0;
int battery_percent = 0;
int battery_time = 0;
const int fd = open(proc_apm_path, O_RDONLY);
const int fd = open(proc_apm_path, O_RDONLY | O_CLOEXEC);
char buf[128];
char *ptr = &buf[0];
char *str = NULL;