我正在使用 msgget() 系统调用来获取新的消息队列。我在其中使用了 IPC_CREAT 和 IPC_EXCL 标志。喜欢message_queue = msgget(ftok("/tmp", 100), (0666 | IPC_CREAT | IPC_EXCL));
现在,当我的 prog 意外存在时,消息队列仍然存在,并且我无法重新创建消息队列。所以,我的问题是“如何取回现有消息队列的 ID?”
顺便问一下,msg 队列在哪里存储它的 id ?
Regd“如何取回现有消息队列的 ID ?”
来自 man msgget
If msgflg specifies both IPC_CREAT and IPC_EXCL and a message queue already exists for key, then msgget() fails with errno set to EEX-
IST. (This is analogous to the effect of the combination O_CREAT | O_EXCL for open(2).)
尝试不使用 IPC_EXCL 标志。
注册。 msg 队列在哪里存储它的 id
来自 人进程
/proc/sysvipc
Subdirectory containing the pseudo-files msg, sem and shm. These files list the System V Interprocess Communication (IPC)
objects (respectively: message queues, semaphores, and shared memory) that currently exist on the system, providing similar
information to that available via ipcs(1). These files have headers and are formatted (one IPC object per line) for easy under-
standing. svipc(7) provides further background on the information shown by these files.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)