Message queues. Possibly dumb mistake.

Geoff Vona geoff at antel.uucp
Fri Dec 8 02:02:05 AEST 1989


Hope someone can help me with this.  Its gotta be something stupid that
I'm doing, but...

I'm trying to use messages and queues under 386/ix 2.0.2 and I'm having
problems.  In msgsnd and msgrcv, messages are passed using a structure
called msgbuf that looks like this:

struct msgbuf {
long mtype;
char mtext[1];
};

(from /usr/include/sys/msg.h)

However, my documentation (?) sez it should be

struct msgbuf {
long mtype;
char mtext[];
};

What I want to do is pretty simple: Assign a string of text (something
profound like "This is a test") to this buffer and send it to another
process that I start up. In other words;

strcpy(gumby.mtext,"This is a test");
gumby.mtype = 2;
result = msgsnd(qid,&gumby,strlen(gumby.mtext),flag);

Unfortunately, I can't create any space for the buffer because its
only a char[1].

Maybe I'm using the wrong mechanism?  (Maybe I should be sent to remedial C
school!)  Please respond by e-mail if the solution is simple and would
simply clutter up the net.

-- 
Geoff Vona                 	| "One likes to believe 
Antel Optronics Inc. 		| In the freedom of music
3325B Mainway Burlington,	| But glittering prizes
Ontario, Canada  L7M 1A6	| And endless compromises



More information about the Comp.unix.i386 mailing list