12-28-2001
11,
0
Join Date: Dec 2001
Last Activity: 26 December 2007, 3:16 AM EST
Location: GUANGZHOU CHINA
Posts: 11
Thanks Given: 0
Thanked 0 Times in 0 Posts
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;
}