程序在执行msgsnd时出错:
invalid argument
man msgsnd
对EINVAL错误的解释是:
EINVAL The value of msqid is not a valid message queue identifier, or
the value of mtype is less than 1; or the value of msgsz is
less than 0 or greater than the system-imposed limit.
忘了检查msgget的返回值了,果然错误在msgget这里:
msgsnd invalid argument
man msgget
对ENOSPC错误的解释是:
ENOSPC A message queue identifier is to be created but the system-
imposed limit on the maximum number of allowed message queue
identifiers system-wide would be exceeded.
msgmni的缺省值为16,也就是系统内部缺省最多可以存在16个消息队列.重新配置内核参数:
echo 64 > /proc/sys/kernel/msgmni
在/etc/sysctl.conf添加一行:
kernel.msgmni = 64
再运行刚才的程序就OK了.
阅读(3171) | 评论(0) | 转发(0) |