Sys V IPC: My final word

Theodore Hope hope at gatech.CSNET
Wed Feb 12 07:33:35 AEST 1986


Since I'm the one who originally asked for info regarding the use of the
message queue system calls, let me say a few things.  First of all, thanks
to all who responded.

The man pages for msgop(2) describe the msgbuf struct as containing

	long mtype;     /* message type */
	char mtext [];  /* message text */

This kind of struc, especially in a syscall-passing sense, seems odd to me.
It is obvious that mtext should be

	char mtext [some_number];

"Oh," said I.  "I'll bet that's a misprint.  Let's look at the <sys/msg.h>
file to see what they _really_ mean."  Well, surprise.  The .h file defines

	struct msgbuf {
	   long mtype;
	   char mtext [1];	<- Notice: it says [1]
	}

Am I overlooking something obvious?  After looking through the kernel source,
it appeared that the msgsnd and msgrcv syscalls expect the data to start at 
msg.mtext, so by defining my own structs as

	struct Msgbuf {
	   long mtype;
	   char mtext [MAXMTEXT];
	}

everything is ok.


Several folks suggested to read the Sys V IPC Primer, which I don't have handy.
Others suggested the book "Advanced Systems Programming with Unix" (I can't
remember the authors' names).
-- 
Theodore Hope
School of Information & Computer Science, Georgia Tech, Atlanta GA 30332
CSNet:	hope at gatech		ARPA:	Hope%GATech.CSNet @ CSNet-Relay.ARPA
uucp:	...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-sally}!gatech!hope



More information about the Comp.unix mailing list