mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
hosted: Use O_CLOEXEC for all open() and "e" for fopen() calls
This way we'll automatically close the files upon exec() Change-Id: Ic0daca8fb56432830de4a2f4a86a77337121ecc7
This commit is contained in:
parent
4f8736909a
commit
5cfd3ae4e6
14 changed files with 27 additions and 31 deletions
|
@ -69,7 +69,7 @@ int os_relate(const char *ospath1, const char *ospath2)
|
|||
}
|
||||
|
||||
/* First file must stay open for duration so that its stats don't change */
|
||||
int fd1 = os_open(ospath1, O_RDONLY);
|
||||
int fd1 = os_open(ospath1, O_RDONLY | O_CLOEXEC);
|
||||
if (fd1 < 0)
|
||||
return -2;
|
||||
|
||||
|
@ -144,7 +144,7 @@ int os_relate(const char *ospath1, const char *ospath2)
|
|||
|
||||
bool os_file_exists(const char *ospath)
|
||||
{
|
||||
int sim_fd = os_open(ospath, O_RDONLY, 0);
|
||||
int sim_fd = os_open(ospath, O_RDONLY | O_CLOEXEC, 0);
|
||||
if (sim_fd < 0)
|
||||
return false;
|
||||
|
||||
|
@ -157,7 +157,7 @@ bool os_file_exists(const char *ospath)
|
|||
|
||||
int os_opendirfd(const char *osdirname)
|
||||
{
|
||||
return os_open(osdirname, O_RDONLY);
|
||||
return os_open(osdirname, O_RDONLY | O_CLOEXEC);
|
||||
}
|
||||
|
||||
int os_opendir_and_fd(const char *osdirname, DIR **osdirpp, int *osfdp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue