From 91c4bf470fd10f4ee54f83ca85c7eecc53bedebb Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 7 Nov 2016 11:19:41 -0200 Subject: [PATCH] AP_InertialSensor: 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. --- libraries/AP_InertialSensor/examples/VibTest/VibTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_InertialSensor/examples/VibTest/VibTest.cpp b/libraries/AP_InertialSensor/examples/VibTest/VibTest.cpp index a65f467977..6e180d14f5 100644 --- a/libraries/AP_InertialSensor/examples/VibTest/VibTest.cpp +++ b/libraries/AP_InertialSensor/examples/VibTest/VibTest.cpp @@ -66,8 +66,8 @@ void setup(void) char gyro_path[] = GYRO_BASE_DEVICE_PATH "n"; accel_path[strlen(accel_path)-1] = '0'+i; gyro_path[strlen(gyro_path)-1] = '0'+i; - accel_fd[i] = open(accel_path, O_RDONLY); - gyro_fd[i] = open(gyro_path, O_RDONLY); + accel_fd[i] = open(accel_path, O_RDONLY|O_CLOEXEC); + gyro_fd[i] = open(gyro_path, O_RDONLY|O_CLOEXEC); } if (accel_fd[0] == -1 || gyro_fd[0] == -1) { AP_HAL::panic("Failed to open accel/gyro 0");