From 87add05a41c5e43764ebbdb8876b343fe9a0f4d9 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 20 Nov 2023 08:18:03 +0100 Subject: [PATCH] host.c: print_backtrace: glibc <2.27 compat CentOS 7 has glibc 2.17 not supporting memfd_create, so use the generic POSIX solution as for macOS. Also switched the condition to this be used always but when glibc 2.27+ was not detected. --- src/host.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/host.cpp b/src/host.cpp index f52b6d8ce3..a807b30692 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -1059,14 +1059,14 @@ print_backtrace() #ifndef _WIN32 // print to a temporary file to avoid interleaving from multiple // threads -#ifdef __APPLE__ +#ifdef __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 27) + int fd = memfd_create("ultragrid_backtrace", MFD_CLOEXEC); +#else char path[MAX_PATH_SIZE]; snprintf(path, sizeof path, "%s/ug-%u", get_temp_dir(), pthread_mach_thread_np(pthread_self())); int fd = open(path, O_CLOEXEC | O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); unlink(path); -#else - int fd = memfd_create("ultragrid_backtrace", MFD_CLOEXEC); #endif if (fd == -1) { fd = STDERR_FILENO;