Make sure SDL file descriptors don't leak into child processes

This commit is contained in:
Sam Lantinga
2021-09-08 14:47:40 -07:00
parent 3ed8ba7d33
commit bf97c5a22f
15 changed files with 24 additions and 24 deletions

View File

@@ -302,7 +302,7 @@ MaybeAddDevice(const char *path)
}
}
fd = open(path, O_RDONLY, 0);
fd = open(path, O_RDONLY | O_CLOEXEC, 0);
if (fd < 0) {
return -1;
}
@@ -963,7 +963,7 @@ PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item)
&joystick->naxes,
&joystick->nhats);
} else {
const int fd = open(item->path, O_RDWR, 0);
const int fd = open(item->path, O_RDWR | O_CLOEXEC, 0);
if (fd < 0) {
return SDL_SetError("Unable to open %s", item->path);
}