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

@@ -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));