Browse Source

AP_HAL: add O_CLOEXEC in places missing it

By opening with O_CLOEXEC we make sure we don't leak the file descriptor
when we are exec'ing or calling out subprograms. Right now we currently
don't do it so there's no harm, but it's good practice in Linux to have
it.
master
Lucas De Marchi 8 years ago
parent
commit
7968736b1c
  1. 2
      libraries/AP_HAL/utility/dsm.cpp
  2. 2
      libraries/AP_HAL/utility/srxl.cpp

2
libraries/AP_HAL/utility/dsm.cpp

@ -464,7 +464,7 @@ static uint64_t micros64(void) @@ -464,7 +464,7 @@ static uint64_t micros64(void)
int main(int argc, const char *argv[])
{
int fd = open(argv[1], O_RDONLY);
int fd = open(argv[1], O_RDONLY|O_CLOEXEC);
if (fd == -1) {
perror(argv[1]);
exit(1);

2
libraries/AP_HAL/utility/srxl.cpp

@ -177,7 +177,7 @@ static uint64_t micros64(void) @@ -177,7 +177,7 @@ static uint64_t micros64(void)
int main(int argc, const char *argv[])
{
int fd = open(argv[1], O_RDONLY);
int fd = open(argv[1], O_RDONLY|O_CLOEXEC);
if (fd == -1) {
perror(argv[1]);
exit(1);

Loading…
Cancel
Save