msgctl(2) 可更改消息队列的权限和其他特性。 msqid 参数必须为现有消息队列的 ID。 cmd 参数为以下各项之一:
以下代码说明了 msgctl(2) 及其各种标志。
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
...
if (msgctl(msqid, IPC_STAT, &buf) == -1) {
perror("msgctl: msgctl failed");
exit(1);
}
...
if (msgctl(msqid, IPC_SET, &buf) == –1) {
perror("msgctl: msgctl failed");
exit(1);
}
...