backend: use fcntl(F_DUPFD_CLOEXEC) instead of dup

This makes sure the CLOEXEC flag is set on the dup'ed FD.
This commit is contained in:
Simon Ser 2020-12-15 20:52:53 +01:00
parent 1ca4d6b029
commit 87bd718de5
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 16 additions and 13 deletions

View file

@ -1,4 +1,6 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
@ -335,9 +337,9 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
goto error_event;
}
drm_fd = dup(drm_fd);
drm_fd = fcntl(drm_fd, F_DUPFD_CLOEXEC, 0);
if (drm_fd < 0) {
wlr_log_errno(WLR_ERROR, "dup failed");
wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed");
goto error_event;
}