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,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)
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, 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)
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)
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)
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)
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)
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 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)
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)
Discussion started by: remic
3 Replies
LEARN ABOUT SUNOS
msgget
msgget(2) System Calls msgget(2)NAME
msgget - get message queue
SYNOPSIS
#include <sys/msg.h>
int msgget(key_t key, int msgflg);
DESCRIPTION
The msgget() argument returns the message queue identifier associated with key.
A message queue identifier and associated message queue and data structure (see intro(2)) 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.
On creation, the data structure associated with the new message queue identifier is initialized as follows:
o msg_perm.cuid, msg_perm.uid, msg_perm.cgid, and msg_perm.gid are set to the effective user ID and effective group ID, respectively, of
the calling process.
o The low-order 9 bits of msg_perm.mode are set to the low-order 9 bits of msgflg.
o msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime are set to 0.
o msg_ctime is set to the current time.
o msg_qbytes is set to the system limit. See NOTES.
RETURN VALUES
Upon successful completion, a non-negative integer representing a message queue identifier is returned. Otherwise, -1 is returned and errno
is set to indicate the error.
ERRORS
The msgget() function will fail if:
EACCES A message queue identifier exists for key, but operation permission (see intro(2)) as specified by the low-order 9 bits of
msgflg would not be granted.
EEXIST A message queue identifier exists for key but (msgflg&IPC_CREAT) and (msgflg&IPC_EXCL) are both true.
ENOENT A message queue identifier does not exist for key and (msgflg&IPC_CREAT) is false.
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. See NOTES.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO rctladm(1M), intro(2), msgctl(2), msgrcv(2), msgsnd(2), setrctl(2), ftok(3C), attributes(5), standards(5)NOTES
The system-defined limit used to initialize msg_qbytes is the minimum enforced value of the calling process's process.max-msg-qbytes
resource control.
The system-imposed limit on the number of message queue identifiers is maintained on a per-project basis using the project.max-msg-ids
resource control.
See rctladm(1M) and setrctl(2) for information about using resource controls.
SunOS 5.10 11 Feb 2003 msgget(2)