mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-21 20:53:52 +08:00
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.
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user