occasionally,after I creat a message queue(ps:msg for short),the program will announce "No space left on device".
Then I use "ipcs" to check msg information,it shows as following:
--------------------------------------------start
[root@localhost udp]# ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
------ Semaphore Arrays --------
key semid owner perms nsems
------ Message Queues --------
key msqid owner perms used-bytes messages
0x00000000 65536 root 0 0 0
0x00000000 98305 root 0 0 0
0x00000000 131074 root 0 0 0
0x00000000 163843 root 0 0 0
0x00000000 196612 root 0 0 0
0x00000000 229381 root 0 0 0
0x00000000 262150 root 0 0 0
0x00000000 294919 root 0 0 0
0x00000000 327688 root 0 0 0
0x00000000 360457 root 0 0 0
0x00000000 393226 root 0 0 0
0x00000000 425995 root 0 0 0
0x00000000 458764 root 0 0 0
0x00000000 491533 root 0 0 0
0x00000000 524302 root 0 0 0
0x00000000 557071 root 0 0 0
[root@localhost udp]#
---------------------------------------------end
The program I use to creat msg as following:
-----------------------------------------------start
#include <sys/types.h>
#include <sys/msg.h>
#include <unistd.h>
#include<errno.h>
extern int errno;
#define MSGPERM 0666
int initmsg(key_t key)
{
int msgid;
int status=0;
if((msgid=msgget(key,IPC_CREAT|MSGPERM))==-1)
{
if(errno==EEXIST)
msgid=msgget(key,MSGPERM); //get the msgid which exists
else
{
perror("initmsg() failed");
return -1;
}
printf("msg get in fun:%d\n",msgid);
return msgid;
}
printf("msg creat in fun:%d\n",msgid);
return msgid;
}
-------------------------------------------------end
Then I delete a msg manually,but the line is taken up by another msg which has the same key.
At this moment ,I can't creat any msg.Only after I restart my PC ,it works.
Please tell me if there are some other method to resolve this problem.
Thank you!