Unsolved Can't create Posix semaphore in the location where the Qt creates QSystemSemaphore
On Linux system QSystemSemaphore created in /tmp directory.
I'd like to share the semaphore with C++ application.
According to the Qt sources it uses Posix command sem_open().
I did the same with my C++ and name: /tmp/qipc_systemsem_somehashtag but i got fail on wrong name.
In C++, using sem_open, i'm able to create only at default location, means /dev/shm/, and the system always add sem. prefix.
How is it possible ? It uses same API (sem_open(...) ).
How can i recreate the Qt semaphore on C++ ?
kshegunov Moderators last edited by
What flags are you passing in your C++ code, and which process is starting first? Are you handling the
If both O_CREAT and O_EXCL are specified in oflag, then an error is returned if a semaphore with the given name already exists.
Yes, i'm handling sem_open errors i similar way
I'm trying to create the semaphore with O_CREAT only flag, which is mean that it first trys to open existing semaphore, and, if not available, it creates one.
So From this point it should never get NULL.
The name i set is, as i said, string /tmp/qipc_systemsem_somehashtag.
I'm testing it when no semaphore with this name exists in both places.
The errno i get is EINVAL (2) which means in my case - wrong name format.
When i set the name without /tmp/ i get semaphore created successfully but at /dev/shm/.
I read some info regarding this problem - it looks like problem in Qt.
Somehow it uses different (wrong) implementation of sem_open, not according the Posix standard.
kshegunov Moderators last edited by kshegunov
Unfortunately, I don't know what the problem might be. :|
What about checking
Do you have available resources?
Have you tried without the
Can you verify you have permissions for the file?