I have a Linux C program where I'm passing data between threads. I was looking into using POSIX message queues to solve this since they don't require mutexes/locks.
Looking at the mq_open() call, I have to specify permissions and the path to the queue. This leads me to two questions.
- Is there a well known convention for specifying the filepath? I was just going to dump the queues in the same folder as the executable.
- In terms of permissions, I was going to use 0600, but I want to restrict this even further to prevent other processes from accessing the queues (I'm sharing data between threads and not processes). Given that the queue is "just" a file, can I use flock() with LOCK_EX to prevent accesses from other processes?
Thanks in advance.