typedef struct
{
char data[MESSAGE_SIZE];
} MESSAGE;
typedef struct
{
sem_t sem_send;
sem_t sem_receive;
MESSAGE messages[];
} MQ;
Currently working on message queue, I want to delete the queue but in order to do so I need to destroy the semaphore (sem_destroy ) then shm_unlink but I need to be sure that there is no process currently connected to the queue
How can I achieve this please ?
Maybe what you want is a UNIX socket instead of a message queue. Check man 7 unix
, there's an example of how to use it. With UNIX sockets you get:
The message queues don't tell anything about other processes connecting to it. Message queues can exist without any process attach to it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.