I have two processes sender and receiver. Sender generates queue (msgget()) with some key e.g. 938, for output.
Receiver reads from the same queue. i.e. receiver also tries to get queue id calling msgget() function and using same key, 938 that sender used.
But the qid that sender is receiving from msgget() function is 16777219 and receiver is getting different qid. Ideally it should get the same qid i.e. 16777219.
I tried to remove this queue using
ipcrm -q <qid>
And I tried to bring up sender with key as 338. But still it is building qid as such huge number and receiver is getting different qid.
Now I am able to read from this queue.
But still not sure whether this qid is correct or not
While not extremely experienced in this subject, it strikes me that if the id's were guaranteed to be the identical, they wouldn't need keys to find them.
test1.c:
test2.c:
I used the above bits of test code to check if at any point the message queue id changed. It didn't
In fact, the man page of msgget makes it quite clear:
Quote:
The msgget() argument returns the message queue identifier
associated with key.
A message queue identifier and associated message queue and
data structure (see intro(3)) are created for key if one of
the following are true:
o key is IPC_PRIVATE.
o key does not already have a message queue identifier
associated with it, and (msgflg&IPC_CREAT) is true.
Remember that msgget will always return a queue id that is associated with the key. This means that if there is already a queueid that is associated with the key, thats what you'll get. A new queue id is only created under the circumstances specified (key is IPC_PRIVATE or queueid does not already exist).
So if you have a program that created a message queue with a certain key, then another program that tries to create a message queue with the same key will *always* get the existing message queue id ,unless one of the programs removes the queue from the system.
In your case, if you have two programs, is one of the programs removing the message queue before the second one can access it? If this happens, then the queue id associated with your key will no longer exist and you will get a new queue id.
And don't worry about the size of the queue id. It makes no difference to your program.
Hi everyone,
I am experiencing discontinuity of Internet service, this started 1 month ago. Everything worked very well for 1 year of intensive use, but now, I have problems reaching my gateway.
The gateway is not my router but a node belonging to my ISP and I share the same public IP with... (3 Replies)
I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore.
Here is what 's happening:
* I wanted to remove lines containing digits so I used this... (25 Replies)
Greetings:
I am posting this because my searches for this problem only came up with two posts and no helpful suggestions. I have a "solution" (read work-around hack) and have not tried yet to find a root cause, and may never because I am busy doing other things (read working to pay the bills).
... (10 Replies)
I want to use msgget() to obtain a message queue between two processes, here is my code:
the first one create the mq, the second one open it and add a message to it. But when I execute the second one, I get permission denied. I've already desperately tried everything I can think of to solve this... (2 Replies)
Hi,
This is rather a question from a "user" than from a sys admin, but I think this forum is apropriate for the question.
I have an adress with automatic email forwarding and for some senders (two hietherto), emails are bouncing. This has really created a lot of problems those two time so I... (0 Replies)
At work I am trying to get this one Linux machine (let's call it ctesgm07) to behave like another Linux machine that we have (let's call it test007).
test007 returns the following version info:
cat /etc/debian_version: lenny/sid
uname -a: Linux test007 2.6.27-7-generic #1 SMP Tue Nov 4... (0 Replies)
1) when user login to the server the session got colosed. How will resolve?
2) While firing the command ls -l we are not able to see the any files in the director. but over all view the file system using the command df -g it is showing 91% used. what will be the problem?
Thanks in advance. (1 Reply)
Hi, folks.
Sorry for bothering, but maybe someone could help me please.
The problem is the following:
there is some script that copies files from local file system to AFS. The copying is performed with dd command.
The script copies data into some AFS volumes.
The problem appeared with one... (0 Replies)
Hi,
Just recently we seem to be getting the following error message relating to SSH when we run the UNIX script in background mode:
warning: You have no controlling tty. Cannot read confirmation.^M
warning: Authentication failed.^M
Disconnected; key exchange or algorithm negotiation... (1 Reply)
hi,all
i have in trouble about msgget.
i create a queue and the program like blow:
openMsg( pid_t key )
{
....
int msgid;
....
msgid=msgget(key,IPC_CREAT|IPC_EXCL|0666)
if( msgid<=0 ){
fprintf( stdout,"%s,%d",strerror(errno),errno );
return -1;
... (9 Replies)