[comp.unix.wizards] System V Message Queue Question

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
machine it ran on.  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