diff --git a/Foundation/src/NamedEvent_UNIX.cpp b/Foundation/src/NamedEvent_UNIX.cpp index 5d78401bb..d0c73886c 100644 --- a/Foundation/src/NamedEvent_UNIX.cpp +++ b/Foundation/src/NamedEvent_UNIX.cpp @@ -57,13 +57,13 @@ NamedEventImpl::NamedEventImpl(const std::string& name): std::string fileName = getFileName(); #if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) _sem = sem_open(fileName.c_str(), O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, 0); - if ((long) _sem == (long) SEM_FAILED) + if ((long) _sem == (long) SEM_FAILED) throw SystemException(Poco::format("cannot create named mutex %s (sem_open() failed, errno=%d)", fileName, errno), _name); #else - int fd = open(fileName.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int fd = open(fileName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd != -1) close(fd); - else + else throw SystemException(Poco::format("cannot create named event %s (lockfile)", fileName), _name); key_t key = ftok(fileName.c_str(), 0); if (key == -1) @@ -128,7 +128,7 @@ void NamedEventImpl::waitImpl() { err = semop(_semid, &op, 1); } - while (err && errno == EINTR); + while (err && errno == EINTR); if (err) throw SystemException("cannot wait for named event", _name); #endif } diff --git a/Foundation/src/NamedMutex_UNIX.cpp b/Foundation/src/NamedMutex_UNIX.cpp index 13677569f..26494dced 100644 --- a/Foundation/src/NamedMutex_UNIX.cpp +++ b/Foundation/src/NamedMutex_UNIX.cpp @@ -57,13 +57,13 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name): std::string fileName = getFileName(); #if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) _sem = sem_open(fileName.c_str(), O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, 1); - if ((long) _sem == (long) SEM_FAILED) + if ((long) _sem == (long) SEM_FAILED) throw SystemException(Poco::format("cannot create named mutex %s (sem_open() failed, errno=%d)", fileName, errno), _name); #else - int fd = open(fileName.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int fd = open(fileName.c_str(), O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (fd != -1) close(fd); - else + else throw SystemException(Poco::format("cannot create named mutex %s (lockfile)", fileName), _name); key_t key = ftok(fileName.c_str(), 0); if (key == -1)