aboutsummaryrefslogtreecommitdiff
path: root/zencore/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/thread.cpp')
-rw-r--r--zencore/thread.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/zencore/thread.cpp b/zencore/thread.cpp
index 313f253f1..df8cb7a34 100644
--- a/zencore/thread.cpp
+++ b/zencore/thread.cpp
@@ -28,6 +28,7 @@
# include <signal.h>
# include <sys/file.h>
# include <sys/sem.h>
+# include <sys/stat.h>
# include <sys/wait.h>
# include <time.h>
# include <unistd.h>
@@ -270,11 +271,12 @@ NamedEvent::NamedEvent(std::string_view EventName)
ExtendableStringBuilder<64> EventPath;
EventPath << "/tmp/" << EventName;
- int Fd = open(EventPath.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0666);
+ int Fd = open(EventPath.c_str(), O_RDWR | O_CREAT | O_CLOEXEC);
if (Fd < 0)
{
ThrowLastError(fmt::format("Failed to create '{}' for named event", EventPath));
}
+ fchmod(Fd, 0666);
// Use the file path to generate an IPC key
key_t IpcKey = ftok(EventPath.c_str(), 1);
@@ -446,11 +448,12 @@ NamedMutex::Create(std::string_view MutexName)
ExtendableStringBuilder<64> Name;
Name << "/tmp/" << MutexName;
- int Inner = open(Name.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0666);
+ int Inner = open(Name.c_str(), O_RDWR | O_CREAT | O_CLOEXEC);
if (Inner < 0)
{
return false;
}
+ fchmod(Inner, 0666);
if (flock(Inner, LOCK_EX) != 0)
{
@@ -489,7 +492,7 @@ NamedMutex::Exists(std::string_view MutexName)
Name << "/tmp/" << MutexName;
bool bExists = false;
- int Fd = open(Name.c_str(), O_RDWR | O_CLOEXEC, 0666);
+ int Fd = open(Name.c_str(), O_RDWR | O_CLOEXEC);
if (Fd >= 0)
{
if (flock(Fd, LOCK_EX | LOCK_NB) == 0)