libsync: replace dup() with os_dupfd_cloexec()

dup() will leak the new FD into any child process after fork().

Signed-off-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26203>
This commit is contained in:
Simon Ser 2025-02-12 20:59:53 +01:00 committed by Marge Bot
parent 42509180d4
commit e4ff98bacb

View file

@ -40,6 +40,7 @@
#include <time.h>
#include "util/detect_os.h"
#include "util/os_file.h"
#if defined(__cplusplus)
extern "C" {
@ -222,7 +223,7 @@ static inline int sync_accumulate(const char *name, int *fd1, int fd2)
assert(fd2 >= 0);
if (*fd1 < 0) {
*fd1 = dup(fd2);
*fd1 = os_dupfd_cloexec(fd2);
return 0;
}