From: fred@genesis.demon.co.uk (Lawrence Kirby)
Subject: Re: Digital Unix message queue programming problem!!
Date: 1997/02/27 [thread overview]
Message-ID: <857065180snz@genesis.demon.co.uk> (raw)
In-Reply-To: 33162B5F.437B@silicon.net.my
In article <33162B5F.437B@silicon.net.my>
fskok@silicon.net.my "Kok Fock Seng" writes:
>Hi out there,
>
>I am writing a program utilize the message queue (IPC) feature
>in Dec Unix.
Note that your question was not about the C language so it wasnt' really
appropriate to cross-post to comp.lang.c. (Removed from follow-ups)
>void main ()
Since you have cross-posted to comp.lang.c I'd just point out that C defines
main as a function returning int. More specifically as either:
int main(void)
or
int main(int argc, char *argv[])
>{
> int messageid;
>
> m.msgtype = 1L ;
> strcpy(m.msgbuf,"This is a test msg!") ;
>
> if (( messageid = msgget ((key_t)(6000L), IPC_CREAT)) == -1 )
(pretending I'm reading this in comp.unix.programmer)
There is a problem here in that you failed to give any read/write
permissions on the queue. Check your man page more carefully for what
the 2nd argument should be (it is basically a collection of bit flags
similar to the 2nd argument of open())
> exit (-1);
Why -1? C defines 0, EXIT_SUCCESS and EXIT_FAILURE. Unix essentially
takes the lower order 8 bits of the value (i.e. a value 0-255) although
some shells may have a weirdness of treating this like a signed char.
> fprintf(stderr, "[%d]", messageid);
>
> if ( msgsnd ( messageid, &m, strlen(m.msgbuf)+1, 0) == -1)
> fprintf(stderr, "Test Queue got problem!\n err [%d]", errno);
> else fprintf(stderr, "Test Queue OK!\n");
> printf(stderr, "[%d]\n", errno) ;
You need to make up your mind whether to printf this to stdout or
fprintf it to stderr! :-)
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
next prev parent reply other threads:[~1997-02-27 5:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-02-27 5:00 Digital Unix message queue programming problem!! Kok Fock Seng
1997-02-27 5:00 ` Charles M Richmond
1997-02-27 5:00 ` Kok Fock Seng
1997-02-27 5:00 ` Lawrence Kirby [this message]
1997-02-28 5:00 ` Andy Knight
1997-02-28 5:00 ` Stephen Baynes
1997-02-27 5:00 ` Jeremy D. Levine
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox