Skip to content

Commit

Permalink
host.c: print_backtrace: glibc <2.27 compat
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MartinPulec committed Nov 20, 2023
1 parent 57b50c3 commit 87add05
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 87add05

Please sign in to comment.