use non-zero project ID ('p') for ftok()

This commit is contained in:
Guenter Obiltschnig 2017-09-11 17:53:34 +02:00
parent a7a8571e25
commit d558d5eef9
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ NamedEventImpl::NamedEventImpl(const std::string& name):
close(fd);
else
throw SystemException(Poco::format("cannot create named event %s (lockfile)", fileName), _name);
key_t key = ftok(fileName.c_str(), 0);
key_t key = ftok(fileName.c_str(), 'p');
if (key == -1)
throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
_semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);

View File

@ -65,7 +65,7 @@ NamedMutexImpl::NamedMutexImpl(const std::string& name):
close(fd);
else
throw SystemException(Poco::format("cannot create named mutex %s (lockfile)", fileName), _name);
key_t key = ftok(fileName.c_str(), 0);
key_t key = ftok(fileName.c_str(), 'p');
if (key == -1)
throw SystemException(Poco::format("cannot create named mutex %s (ftok() failed, errno=%d)", fileName, errno), _name);
_semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);