mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 17:06:25 +00:00
Make sure SDL file descriptors don't leak into child processes
This commit is contained in:
@@ -260,7 +260,7 @@ MaybeAddDevice(const char *path)
|
||||
}
|
||||
|
||||
/* try to open */
|
||||
fd = open(path, O_RDWR, 0);
|
||||
fd = open(path, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ SDL_SYS_HapticName(int index)
|
||||
item = HapticByDevIndex(index);
|
||||
/* Open the haptic device. */
|
||||
name = NULL;
|
||||
fd = open(item->fname, O_RDONLY, 0);
|
||||
fd = open(item->fname, O_RDONLY | O_CLOEXEC, 0);
|
||||
|
||||
if (fd >= 0) {
|
||||
|
||||
@@ -453,7 +453,7 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic)
|
||||
|
||||
item = HapticByDevIndex(haptic->index);
|
||||
/* Open the character device */
|
||||
fd = open(item->fname, O_RDWR, 0);
|
||||
fd = open(item->fname, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
item->fname, strerror(errno));
|
||||
@@ -483,7 +483,7 @@ SDL_SYS_HapticMouse(void)
|
||||
|
||||
for (item = SDL_hapticlist; item; item = item->next) {
|
||||
/* Open the device. */
|
||||
fd = open(item->fname, O_RDWR, 0);
|
||||
fd = open(item->fname, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
item->fname, strerror(errno));
|
||||
@@ -570,7 +570,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
||||
return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities");
|
||||
}
|
||||
|
||||
fd = open(joystick->hwdata->fname, O_RDWR, 0);
|
||||
fd = open(joystick->hwdata->fname, O_RDWR | O_CLOEXEC, 0);
|
||||
if (fd < 0) {
|
||||
return SDL_SetError("Haptic: Unable to open %s: %s",
|
||||
joystick->hwdata->fname, strerror(errno));
|
||||
|
Reference in New Issue
Block a user