mirror of https://github.com/ArduPilot/ardupilot
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:
parent
b7e5f56bd7
commit
91c4bf470f
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue