Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mcnc!rti!xyzzy!paranoia!rice From: rice@dg-rtp.dg.com (Brian Rice) Newsgroups: comp.unix.wizards Subject: Re: Message queues (System V) Keywords: delete private queues Message-ID: <794@xyzzy.UUCP> Date: 3 Mar 90 20:01:49 GMT References: <7114@lynx.UUCP> Sender: usenet@xyzzy.UUCP Reply-To: rice@dg-rtp.dg.com (Brian Rice) Followup-To: comp.unix.questions Distribution: na Organization: Data General Corporation, Research Triangle Park, NC Lines: 32 In article <7114@lynx.UUCP>, m5@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@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."