about msgget troble


 
Thread Tools Search this Thread
Top Forums Programming about msgget troble
# 1  
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
# 2  
Old 12-28-2001
Hi!

It may be because you are not deleting the "Message Queue" before exiting your application. You should be using the command IPC_RMID in your shmctl() function to remove the Message Queue before exiting your program.

Regards
SHAIK
shaik786
# 3  
Old 12-28-2001
yes,but that's not reason

the queue not exist before i run this program.
# 4  
Old 12-28-2001
What is the value of key ?
shaik786
# 5  
Old 12-28-2001
the key is 2101

the key is 2101
# 6  
Old 12-28-2001
Are you sure you are getting the Error Message "Invalid argument" for this msgget()? Maybe the error is on some other function like: msgctl() or msgsnd() or msgrcv() . . .
shaik786
# 7  
Old 12-28-2001
yes i'm sure.

yes, i'm sure.
because i have log file and trace the problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. 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

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

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
Login or Register to Ask a Question