Message queues (System V)

Brian Rice rice at dg-rtp.dg.com
Sun Mar 4 06:01:49 AEST 1990


In article <7114 at lynx.UUCP>, m5 at lynx.uucp (Mike McNally) writes:
> I have recently discovered that message queues with a key of IPC_PRIVATE are
> not implicitly removed when all using tasks exit.
> Is any purpose served by keeping the queue around?

Remember that a "private" message queue is not so private 
that only one process group can use it: in fact, any
process which knows the queue's id (as originally returned 
by msgget()) may read or write from the queue if the queue's 
access permissions are satisfied.

The source of confusion here, I think, is that msgget() does 
not somehow declare that a process is using a queue; it serves
basically two functions: to create a new message queue and to
look up the id of a queue if all you know is the key.  If
I know that somebody else has created a queue whose id is 17,
then I don't need to use msgget() at all.  I can immediately
do a msgsnd(17,...), for instance...even if the queue was
created with IPC_PRIVATE.  All IPC_PRIVATE does is to block
another process's looking up your queue's key.

A process may distribute a message queue id at will--it
may even store it in a file for use by another process
next Wednesday.  For this reason, implicitly killing message
queues not "in use" would make the message queue facility
less useful.  (It's also not clear that, given these facts
about message queues, one can coherently define when a queue
is unused--but that's a whole 'nother bucket of borscht.)

Brian Rice   rice at dg-rtp.dg.com   (919) 248-6328
DG/UX Product Assurance Engineering
Data General Corp., Research Triangle Park, N.C.
"My other car is an AViiON."



More information about the Comp.unix.wizards mailing list