diff --git a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp index f759d15a2b..69686d470e 100644 --- a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp +++ b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp @@ -71,6 +71,7 @@ #if !defined(_WIN32) #include #include +#include #include #endif @@ -145,10 +146,9 @@ public: #else m_fd = ::open(path.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0600); if (m_fd == -1) { m_locked = true; return; } // can't open -> don't block - struct flock fl{}; - fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; int rc; - do { rc = ::fcntl(m_fd, F_SETLKW, &fl); } while (rc == -1 && errno == EINTR); // blocks in kernel + // An fcntl lock would not block other threads in this process, and any close() of this file would release it. + do { rc = ::flock(m_fd, LOCK_EX); } while (rc == -1 && errno == EINTR); // blocks in kernel m_locked = (rc != -1); #endif }