about msgget troble


 
Thread Tools Search this Thread
Top Forums Programming about msgget troble
# 8  
Old 12-28-2001
I dont see any error in the code pasted above, though I still think the error is somewhere else! Why dont you paste the whole program, we'll hopefully solve the problem.
shaik786
# 9  
Old 12-28-2001
ok,this is my program in the form

/* this is main entry */
main()
{
char sErrMsg[100];
EXEC SQL BEGIN DECLARE SECTION;
char sWorkDB[20];
EXEC SQL END DECLARE SECTION;

/* control signal */
signal( SIGCHLD,SIG_IGN );
signal( SIGKILL,exitfunc );
signal( SIGQUIT,exitfunc );
signal( SIGPIPE,SIG_IGN );
signal( SIGTRAP,sigerr );

/* to build a queue */
msgid__=openMsg(2101);
if( msgid__ <=0 ){
fprintf( stderr,"%s\n",strerror(errno) );
fprintf( stderr,"create queue error!!\n" );
exit(-1);
}
.......
}

/* this is the function body about openMsg */
int openMsg( key_t k )
{
int iRtn;
key_t key;
char sFilePath[200];
if( k == 0 ){
/* if k is zero , get key by a file */
sprintf( sFilePath,"%s/MSG_ERR_ID",getenv("CNF_PATH") );
key=ftok(sFilePath,'@');
if( key < 0 ){
errorlog("%s.[%s,%d]",strerror(errno),__FILE__,__LINE__);
return -1;
}
}
else{
key = k;
}

iRtn=msgget(key,IPC_CREAT|IPC_EXCL|0666);
if( iRtn<=0){
errorlog("%s.[%s,%d]",strerror(errno),__FILE__,__LINE__);
}
end:
return iRtn;
}
# 10  
Old 12-28-2001
i have found the problem

just modified the main entry program.main()
{
char sErrMsg[100];
EXEC SQL BEGIN DECLARE SECTION;
char sWorkDB[20];
EXEC SQL END DECLARE SECTION;

signal( SIGCHLD,SIG_IGN );
signal( SIGKILL,exitfunc );
signal( SIGQUIT,exitfunc );
signal( SIGPIPE,SIG_IGN );
signal( SIGTRAP,sigerr );
msgid__=openMsg(SYSMSG_ID);
/*if( msgid__ <=0 ){ this is the trouble*/
if(msgid__<0){
fprintf( stderr,"%s\n",strerror(errno) );
fprintf( stderr,"create queue error!\n" );
exit(-1);
}

Thank for your advices deeply.
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