O_CLOEXEC was added in Mac OS X 10.7. Revert to fcntl() to set the CLOEXEC flag for older system versions. --- ./src/commonui/ipcmutex.cpp.orig 2021-03-19 14:29:09.000000000 +0100 +++ ./src/commonui/ipcmutex.cpp 2023-03-25 19:31:11.000000000 +0100 @@ -42,7 +42,8 @@ fz::scoped_lock lock{private_mutex}; fn = lockfile_path + L"lockfile"; } - m_fd = open(fz::to_native(fn).c_str(), O_CREAT | O_RDWR | O_CLOEXEC, 0644); + m_fd = open(fz::to_native(fn).c_str(), O_CREAT | O_RDWR, 0644); + fcntl(m_fd, F_SETFD, FD_CLOEXEC); } --m_instanceCount; #endif --- ./src/engine/logging.cpp.orig 2020-06-18 16:06:46.000000000 +0200 +++ ./src/engine/logging.cpp 2023-03-25 19:26:47.000000000 +0100 @@ -108,8 +108,10 @@ if (m_log_fd == INVALID_HANDLE_VALUE) { DWORD err = GetLastError(); #else - m_log_fd = open(m_file.c_str(), O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644); - if (m_log_fd == -1) { + m_log_fd = open(m_file.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644); + if (m_log_fd != -1) { + fcntl(m_log_fd, F_SETFD, FD_CLOEXEC); + } else { int err = errno; #endif l.unlock(); //Avoid recursion @@ -272,7 +274,7 @@ while ((rc = fcntl(m_log_fd, F_SETLKW, &lock)) == -1 && errno == EINTR); // Ignore any other failures - int fd = open(m_file.c_str(), O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644); + int fd = open(m_file.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644); if (fd == -1) { int err = errno; @@ -283,6 +285,7 @@ log(logmsg::error, _("Could not open log file: %s"), GetSystemErrorDescription(err)); return; } + fcntl(fd, F_SETFD, FD_CLOEXEC); struct stat buf2; rc = fstat(fd, &buf2); @@ -302,13 +305,14 @@ close(fd); // Get the new file - m_log_fd = open(m_file.c_str(), O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644); + m_log_fd = open(m_file.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644); if (m_log_fd == -1) { int err = errno; l.unlock(); // Avoid recursion log(logmsg::error, _("Could not open log file: %s"), GetSystemErrorDescription(err)); return; } + fcntl(m_log_fd, F_SETFD, FD_CLOEXEC); if (!rc) { // Rename didn't fail --- ./src/interface/edithandler.cpp.orig 2022-04-21 05:30:03.000000000 +0200 +++ ./src/interface/edithandler.cpp 2023-03-25 19:58:15.000000000 +0100 @@ -143,8 +143,9 @@ std::wstring const lockfile = temp + L"fz3temp-lockfile"; if (wxFileName::FileExists(lockfile)) { #ifndef __WXMSW__ - int fd = open(fz::to_string(lockfile).c_str(), O_RDWR | O_CLOEXEC, 0); + int fd = open(fz::to_string(lockfile).c_str(), O_RDWR, 0); if (fd >= 0) { + fcntl(fd, F_SETFD, FD_CLOEXEC); // Try to lock 1 byte region in the lockfile. m_type specifies the byte to lock. struct flock f = {}; f.l_type = F_WRLCK; @@ -234,8 +235,9 @@ } #else auto file = fz::to_native(m_localDir) + "fz3temp-lockfile"; - m_lockfile_descriptor = open(file.c_str(), O_CREAT | O_RDWR | O_CLOEXEC, 0600); + m_lockfile_descriptor = open(file.c_str(), O_CREAT | O_RDWR, 0600); if (m_lockfile_descriptor >= 0) { + fcntl(m_lockfile_descriptor, F_SETFD, FD_CLOEXEC); // Lock 1 byte region in the lockfile. struct flock f = {}; f.l_type = F_WRLCK;