The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with msgget() Ashwini High Level Programming 2 09-14-2006 09:13 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8  
Old 12-28-2001
shaik786
Guest
 

Posts: n/a
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.
Reply With Quote
Forum Sponsor
  #9  
Old 12-28-2001
Registered User
 

Join Date: Dec 2001
Location: GUANGZHOU CHINA
Posts: 11
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;
}
Reply With Quote
  #10  
Old 12-28-2001
Registered User
 

Join Date: Dec 2001
Location: GUANGZHOU CHINA
Posts: 11
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0