mirror of
https://github.com/espressif/openthread.git
synced 2026-08-30 22:09:54 +00:00
[posix] close files on exec (#3977)
This commit adds the *_CLOEXEC flags when opening files. This ensures files are closed when spawning new processes. * use LOG_DAEMON as syslog facility * remove setenv() when forkpty
This commit is contained in:
@@ -1138,7 +1138,7 @@ static bool setup_spi_dev(const char *path)
|
||||
int ret;
|
||||
sSpiDevPath = path;
|
||||
|
||||
fd = open(path, O_RDWR);
|
||||
fd = open(path, O_RDWR | O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
{
|
||||
perror("open");
|
||||
@@ -1212,7 +1212,7 @@ static bool setup_res_gpio(const char *path)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
setup_fd = open(dir_path, O_WRONLY);
|
||||
setup_fd = open(dir_path, O_WRONLY | O_CLOEXEC);
|
||||
|
||||
if (setup_fd >= 0)
|
||||
{
|
||||
@@ -1223,7 +1223,7 @@ static bool setup_res_gpio(const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
sResGpioValueFd = open(value_path, O_WRONLY);
|
||||
sResGpioValueFd = open(value_path, O_WRONLY | O_CLOEXEC);
|
||||
|
||||
bail:
|
||||
|
||||
@@ -1308,7 +1308,7 @@ static bool setup_int_gpio(const char *path)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
setup_fd = open(dir_path, O_WRONLY);
|
||||
setup_fd = open(dir_path, O_WRONLY | O_CLOEXEC);
|
||||
|
||||
if (setup_fd >= 0)
|
||||
{
|
||||
@@ -1322,7 +1322,7 @@ static bool setup_int_gpio(const char *path)
|
||||
close(setup_fd);
|
||||
}
|
||||
|
||||
setup_fd = open(edge_path, O_WRONLY);
|
||||
setup_fd = open(edge_path, O_WRONLY | O_CLOEXEC);
|
||||
|
||||
if (setup_fd >= 0)
|
||||
{
|
||||
@@ -1339,7 +1339,7 @@ static bool setup_int_gpio(const char *path)
|
||||
setup_fd = -1;
|
||||
}
|
||||
|
||||
sIntGpioValueFd = open(value_path, O_RDONLY);
|
||||
sIntGpioValueFd = open(value_path, O_RDONLY | O_CLOEXEC);
|
||||
|
||||
bail:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user