简体   繁体   English

检查IPC消息队列是否已经存在而不创建

[英]Check if a IPC message queue already exists without creating it

How can I just check if a message queue exists or not without making it? 我如何仅检查消息队列是否存在而不进行创建?

When using msgget with O_CREAT | O_EXCL msggetO_CREAT | O_EXCL一起使用时O_CREAT | O_EXCL O_CREAT | O_EXCL flag, if it exists, the call will fail with return value -1, but if it doesn't, it will then create a new message queue. O_CREAT | O_EXCL标志,如果存在,则调用将失败,返回值为-1,但如果不存在,则它将创建一个新的消息队列。 Is there any way to just check? 有什么办法可以检查吗?

ipcs(1) provides information on the IPC facilities and ipcrm(1) can be used to remove the IPC objects from the system. ipcs(1)提供有关IPC设施的信息,并且ipcrm(1)可用于从系统中删除IPC对象。

List shared memory segments: 列出共享内存段:

ipcs -m ipcs -m

List message queues: 列出消息队列:

ipcs -q ipcs -q

Remove shared memory segment created with shmkey: 删除使用shmkey创建的共享内存段:

ipcrm -M key ipcrm -M键

Remove shared memory segment identified by shmid: 删除shmid标识的共享内存段:

ipcrm -m id ipcrm -m ID

Remove message queue created with msgkey: 删除使用msgkey创建的消息队列:

ipcrm -Q key ipcrm -Q键

Remove message queue identified by msgid: 删除msgid标识的消息队列:

ipcrm -q id ipcrm -q id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM