当前位置: 技术问答>linux和unix
怎样在程序中修改一个系统V消息队列中消息的个数::
来源: 互联网 发布时间:2016-12-01
本文导语: 如题:想通过程序中的系统调用修改一个消息队列中消息的个数: 例如:megctl(msqid,IPC_SET,msqid_ds*buf); 但是;书上说只能修改msqid_ds结构中的四个字段:msg _perm.uid、msg_perm_gid、msgg_perm .mode和msg_perm.qbytes. 具体怎样...
如题:想通过程序中的系统调用修改一个消息队列中消息的个数:
例如:megctl(msqid,IPC_SET,msqid_ds*buf);
但是;书上说只能修改msqid_ds结构中的四个字段:msg _perm.uid、msg_perm_gid、msgg_perm .mode和msg_perm.qbytes.
具体怎样设置??高人出手!!!
例如:megctl(msqid,IPC_SET,msqid_ds*buf);
但是;书上说只能修改msqid_ds结构中的四个字段:msg _perm.uid、msg_perm_gid、msgg_perm .mode和msg_perm.qbytes.
具体怎样设置??高人出手!!!
|
查手册。
我经常用"www.die.net"查函数。
IPC_SET
Write the values of some members of the msqid_ds structure pointed to by buf to the kernel data structure associated with this message queue, updating also its msg_ctime member. The following members of the structure are updated: msg_qbytes, msg_perm.uid, msg_perm.gid, and (the least significant 9 bits of) msg_perm.mode. The effective UID of the calling process must match the owner (msg_perm.uid) or creator (msg_perm.cuid) of the message queue, or the caller must be privileged. Appropriate privilege (Linux: the CAP_IPC_RESOURCE capability) is required to raise the msg_qbytes value beyond the system parameter MSGMNB.
确定你的消息大小,把msg_qbytes设置为“消息大小*消息个数”
我经常用"www.die.net"查函数。
struct msqid_ds {
struct ipc_perm msg_perm; /* Ownership and permissions
time_t msg_stime; /* Time of last msgsnd() */
time_t msg_rtime; /* Time of last msgrcv() */
time_t msg_ctime; /* Time of last change */
unsigned long __msg_cbytes; /* Current number of bytes in
queue (non-standard) */
msgqnum_t msg_qnum; /* Current number of messages
in queue */
msglen_t msg_qbytes; /* Maximum number of bytes
allowed in queue */
pid_t msg_lspid; /* PID of last msgsnd() */
pid_t msg_lrpid; /* PID of last msgrcv() */
};
IPC_SET
Write the values of some members of the msqid_ds structure pointed to by buf to the kernel data structure associated with this message queue, updating also its msg_ctime member. The following members of the structure are updated: msg_qbytes, msg_perm.uid, msg_perm.gid, and (the least significant 9 bits of) msg_perm.mode. The effective UID of the calling process must match the owner (msg_perm.uid) or creator (msg_perm.cuid) of the message queue, or the caller must be privileged. Appropriate privilege (Linux: the CAP_IPC_RESOURCE capability) is required to raise the msg_qbytes value beyond the system parameter MSGMNB.
确定你的消息大小,把msg_qbytes设置为“消息大小*消息个数”
|