简体   繁体   English

Posix消息队列和命令行?

[英]Posix message queues and the command line?

I'm writing some code to replace TCP sockets with POSIX message queues. 我正在编写一些代码来替换带有POSIX消息队列的TCP套接字。 Sometimes the program will crash (still in development) and the queues that were created are not deleted (did not execute: mq_close() + mq_unlink() ). 有时程序会崩溃(仍在开发中),并且不会删除创建的队列(不执行: mq_close() + mq_unlink() )。 This causes issues when I run the code again. 当我再次运行代码时,这会导致问题。

Is there a way to delete/remove these queues using the command line? 有没有办法使用命令行删除/删除这些队列? I tried using: ipcs -q . 我尝试使用: ipcs -q This failed to list any queues. 这无法列出任何队列。

I tried: lsof | grep queue-name 我试过了: lsof | grep queue-name lsof | grep queue-name . lsof | grep queue-name They did show up here. 他们确实出现在这里。

Ideally, I'd like to use: ipcrm . 理想情况下,我想使用: ipcrm

POSIX IPC objects are implemented as files in virtual file systems. POSIX IPC对象在虚拟文件系统中实现为文件。 These files can be listed and removed with ls and rm. 可以使用ls和rm列出和删除这些文件。 To do this with POSIX message queues, we must mount the message queue file system using the following commands: 要使用POSIX消息队列执行此操作,我们必须使用以下命令装入消息队列文件系统:

$ su
Password:
# mkdir /dev/mqueue
# mount -t mqueue none /dev/mqueue
# exit

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

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