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.
This commit is contained in:
Lucas De Marchi 2016-11-02 16:02:57 -02:00
parent 4936fd8623
commit 8cec2c188f
2 changed files with 2 additions and 2 deletions

View File

@ -71,7 +71,7 @@ int main (void)
uint32_t *iram;
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);
pwm = (struct pwm*) mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, RCOUT_PRUSS_RAM_BASE);

View File

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