[comp.unix.questions] Sys V Message Queue Question

jon@jonlab.UUCP (Jon H. LaBadie) (03/10/89)

I believe the answer to my question is NO, but I'll ask it to be sure.

    Is there a way to "browse" the messages on a System V
    message queue while leaving them in the queue?
-- 
Jon LaBadie
{att, princeton, bcr}!jonlab!jon
{att, attmail, bcr}!auxnj!jon

noren@dinl.uucp (Charles Noren) (03/15/89)

On one of our Sun systems (Sun 3/280 with SunOS 4.01) I've got
some C code working using System V Message Queues.  Running
the program to any other of our networked machines (3/50, 3/260) 
with SunOS 4.01) the code fails
on the msgget(2) call to create a non-existant message queue.
errno indicates an invalid argument, which was valid on the
Sun 3/280.  Any ideas on what the problem is an how to fix
it?  Is it a sysgen parameter that needs to be changed to allow
message queues?

Sample code:
    /*
     * Create message queue.
     * Create by also checking the existence of the message queue.
     * If the queue exists, the create attempt will fail.
     *        
     * The flags of the first msgget perform the following:
     *
     *   00600                Set the permissions of the message queue
     *                        for read/write by user only.
     *
     *   IPC_CREAT            Create a message queue (defined in
     *                        <sys/ipc.h>).
     *
     *   IPC_EXCL             Perform the operations only if the message
     *                        queue does not already exist (defined in
     *                        <sys/ipc.h>).
     *
     */

    if((qid = msgget(key, 00600 | IPC_CREAT| IPC_EXCL)) == -1)
    {
        /*
         * ...perform error processing.
         *
         */
    }

key is defined as key_t and I have used values from (key_t) 1 thru (key_t) 30.
The errno I get is 22 (EINVAL -- Invalid argument) when I was expecting
an errno of 17 (EEXIST -- File exists, which is what I get on the Sun
that this stuff works on if the queue already exists).
On the Suns that this does not work I cannot even create a "private"
queue (key = IPC_PRIVATE).

Any help will be appreciated.
-- 
Chuck Noren
NET:     ncar!dinl!noren
US-MAIL: Martin Marietta I&CS, MS XL8058, P.O. Box 1260,
         Denver, CO 80201-1260
Phone:   (303) 971-7930

guy@auspex.UUCP (Guy Harris) (03/19/89)

>Is it a sysgen parameter that needs to be changed to allow
>message queues?

There is such a sysgen parameter; you have to put

	options		IPCMESSAGE

into your config file.  The "GENERIC" config file has that, along with

	options		IPCSEMAPHORE
	options		IPCSHMEM

but the other Sun-supplied config files do not.  Make sure the kernel on
all the machines in question was configured with the S5 IPC feature(s)
you want; if not, change the config file and rebuild the kernel.