Sponsored Content
Full Discussion: about msgget troble
Top Forums Programming about msgget troble Post 12370 by subrain on Friday 28th of December 2001 08:40:13 AM
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;
}
 

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
msgid(1M)                                                 System Administration Commands                                                 msgid(1M)

NAME
msgid - generate message IDs SYNOPSIS
/usr/sbin/msgid DESCRIPTION
The msgid utility generates message IDs. A message ID is a numeric identifier that, with a high probability, uniquely identifies a message. The probability of two distinct messages having the same ID is about one in a million. Specifically, the message ID is a hash signature on the message's unexpanded format string, generated by STRLOG_MAKE_MSGID() as defined in <sys/strlog.h>. syslogd(1M) is a simple filter that takes strings as input and produces those same strings, preceded by their message IDs, as output. Every message logged by syslogd(1M) includes the message ID. The message ID is intended to serve as a small, language-independent identifier. EXAMPLES
Example 1: Using the msgid command to generate a message ID The following example uses the msgid command to generate a message ID for the echo command. example# echo hello | msgid 205790 hello Example 2: Using the msgid command to generate a message catalog The following example uses the msgid command to enumerate all of the messages in the binary ufs, to generate a message catalog. example# strings /kernel/fs/ufs | msgid 137713 free: freeing free frag, dev:0x%lx, blk:%ld, cg:%d, ino:%lu, fs:%s 567420 ialloccg: block not in mapfs = %s 845546 alloc: %s: file system full ... ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
syslogd(1M), attributes(5), log(7d) SunOS 5.10 9 Oct 1998 msgid(1M)
All times are GMT -4. The time now is 04:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy