Browse Source

Tools: 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.
mission-4.1.18
Lucas De Marchi 8 years ago
parent
commit
8cec2c188f
  1. 2
      Tools/Linux_HAL_Essentials/pru/aiopru/RcAioPRUTest.c
  2. 2
      Tools/Replay/DataFlashFileReader.cpp

2
Tools/Linux_HAL_Essentials/pru/aiopru/RcAioPRUTest.c

@ -71,7 +71,7 @@ int main (void)
uint32_t *iram; uint32_t *iram;
uint32_t *ctrl; uint32_t *ctrl;
mem_fd = open("/dev/mem", O_RDWR|O_SYNC); mem_fd = open("/dev/mem", O_RDWR|O_SYNC|O_CLOEXEC);
ring_buffer = (struct ring_buffer*) mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, RCIN_PRUSS_RAM_BASE); ring_buffer = (struct ring_buffer*) mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, RCIN_PRUSS_RAM_BASE);
pwm = (struct pwm*) mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, RCOUT_PRUSS_RAM_BASE); pwm = (struct pwm*) mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, RCOUT_PRUSS_RAM_BASE);

2
Tools/Replay/DataFlashFileReader.cpp

@ -8,7 +8,7 @@
bool DataFlashFileReader::open_log(const char *logfile) bool DataFlashFileReader::open_log(const char *logfile)
{ {
fd = ::open(logfile, O_RDONLY); fd = ::open(logfile, O_RDONLY|O_CLOEXEC);
if (fd == -1) { if (fd == -1) {
return false; return false;
} }

Loading…
Cancel
Save