我在我的環境裡, 寫了如下一個php檔案:
$msg_key = ftok(__FILE__, 'a');
$seg = msg_get_queue($msg_key, 0666);
?>
然後用命令列執行不能輸出錯誤.
但在網頁執行的時候, 就會發生以下錯誤:
Warning: msg_get_queue(): failed for key 0x610005bd: File exists in /var/www/html/test/sysvmsg.php on line 4
困擾了我一個下午, 求高手賜教.
我的環境:linux + apache + php 5.3.3
回複討論(解決方案)
看看php的文檔說http://php.net/msg_get_queue
echo 100 > /proc/sys/fs/mqueue/msg_max
ftok 返回一個整數
msg_get_queue 發送一個訊息
十六進位的 0x610005bd 是十進位的 1627391421
你得到並發送的不就是這個數嗎?
If you are getting this message on your *NIX box:
Warning: msg_get_queue() [function.msg-get-queue]: failed for key 0x12345678: No space left on device in /path/to/script.php on line 1
you may use the command "ipcrm" as root to clear the message queue. Use "man ipcrm" to get more info on it.
The default setting for maximum messages in the queue is stored in /proc/sys/fs/mqueue/msg_max. To increase it to a maximum of 100 messages, just run:
echo 100 > /proc/sys/fs/mqueue/msg_max
Please ensure to follow a good programming style and close/free all your message queues before your script exits to avoid those warning messages.
這是手冊裡的,跟你的情況是一致的吧!
你可以用命令ipcrm做為root清楚訊息佇列,再用 man ipcrm得到更多的資訊。
在隊列預設最大的訊息儲存在/proc/sys/fs/mqueue/msg_max裡,想增加最多100條訊息的話,可執行
echo 100 > /proc/sys/fs/mqueue/msg_max
http://www.baidu.com/baidu?wd=Warning%3A+msg_get_queue%28%29%3A+failed+for+key+0x610005bd%3A+File+exists+in+%2Fvar%2Fwww%2Fhtml%2Ftest%2Fsysvmsg.php+on+line+4&tn=monline_dg
最終查明原因是: SELinux未關閉