Sponsored Content
Full Discussion: about msgget troble
Top Forums Programming about msgget troble Post 12353 by subrain on Thursday 27th of December 2001 09:42:37 PM
Old 12-27-2001
about msgget troble

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;
}
else{
return msgid;
}
}

when i open my computer and run this program first ,the answer always is "Invalid argument" .
use ipc to see the queue stat, i found a queue is already exist just like this
"Message Queues
q 0 0x00000835 --rw-rw-rw- iccard informix
"
when i delete the queue ,and restart my program ,everything right.
so why? please tell me.
thank you.


Smilie

Last edited by Perderabo; 03-17-2005 at 11:10 AM.. Reason: Remove email
 

3 More Discussions You Might Find Interesting

1. Programming

Problem with msgget()

Hi, I am having problem with msgget() function. Here is the problem that I am having on Unix : 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... (2 Replies)
Discussion started by: Ashwini
2 Replies

2. Programming

msgget message queue always get permission denied

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)
Discussion started by: tefino
2 Replies

3. Programming

Msgget(2) returns 0 - a workaround fix

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)
Discussion started by: mr_bandit
10 Replies
MSGGET(2)						      BSD System Calls Manual							 MSGGET(2)

NAME
msgget -- get message queue LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> int msgget(key_t key, int msgflg); DESCRIPTION
The msgget() function returns the message queue identifier associated with key. A message queue identifier is a unique integer greater than zero. A message queue is created if either key is equal to IPC_PRIVATE, or key does not have a message queue identifier associated with it, and the IPC_CREAT bit is set in msgflg. If a new message queue is created, the data structure associated with it (the msqid_ds structure, see msgctl(2)) is initialized as follows: o msg_perm.cuid and msg_perm.uid are set to the effective uid of the calling process. o msg_perm.gid and msg_perm.cgid are set to the effective gid of the calling process. o msg_perm.mode is set to the lower 9 bits of msgflg. o msg_cbytes, msg_qnum, msg_lspid, msg_lrpid, msg_rtime, and msg_stime are set to 0. o msg_qbytes is set to the system wide maximum value for the number of bytes in a queue (MSGMNB). o msg_ctime is set to the current time. RETURN VALUES
Upon successful completion a positive message queue identifier is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error. ERRORS
[EACCES] A message queue is already associated with key and the caller has no permission to access it. [EEXIST] Both IPC_CREAT and IPC_EXCL are set in msgflg, and a message queue is already associated with key. [ENOSPC] A new message queue could not be created because the system limit for the number of message queues has been reached. [ENOENT] IPC_CREAT was not set in msgflg and no message queue associated with key was found. SEE ALSO
msgctl(2), msgrcv(2), msgsnd(2) HISTORY
Message queues appeared in the first release of AT&T System V UNIX. BSD
July 9, 2009 BSD
All times are GMT -4. The time now is 04:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy