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;