Message Queue limit for MAC OS X

Discussion in 'Mac Programming' started by pankaj.acs, Oct 5, 2010.

  1. pankaj.acs macrumors newbie

    Oct 5, 2010
    Hello all,

    We have a application where two processes communicate via IPC.
    We are currently using Message Queue for this communication.

    The problem that we are facing is that the Max message that we are able to send through Message Q is only 2048 bytes! :(

    As soon as we send data more than 2048 bytes, msgsend returns -1 with error code: 22 [Invalid arguments].

    We tried increasing the Message Q size using msgctl system call, but to no avail.
    Even though msgctl for msgsize > 2048 returns success, the message Q size remains 2048 only.

    Sample program that i wrote to increase the Message Q size is as follows:

    msgid = msgget((key_t)1234, 0666 | IPC_CREAT);
    printf("\nFailure in msgctl() 1");

    printf("Queue size: %d", (int) queue_ds.msg_qbytes);

    /* Increase Queue size */
    queue_ds.msg_qbytes = 5000;

    printf("\nFailure in msgctl()");
    printf("Queue size updated to: %d", (int) queue_ds.msg_qbytes);

    printf("\nFailure in msgctl() 2");
    printf("Modified Queue size: %d", (int) queue_ds.msg_qbytes);


    Queue size: 2048
    Queue size updated to: 5000
    Modified Queue size: 2048

    Any idea why we are not able to increase the Message Q size?
    Is this a limitation on Mac OS X?

    Appreciate any help/pointers in this regard.

  2. robbieduncan Moderator emeritus


    Jul 24, 2002

    "IPC_SET ... This operation can only be executed by the super-user"

    Are your programs executing as the super-user (running as root or effectively the same)?
  3. pankaj.acs thread starter macrumors newbie

    Oct 5, 2010
    Message Queue limit for MAC OS X

    Yes, i executed the msgctl using super-user only.
    Otherwise, I believe msgctl would have failed.

    However, am eager to know if anyone has actually tried changing the Message Q size in Mac OS X?
    I mean, is it even possible without recompiling the kernel.
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Post complete compilable runnable code, not just a code fragment.

    Why are you using msgq at all? My impression is that it's not designed or intended for large amounts of data. If you have multiple processes, especially unprivileged ones, sending large amounts of data, you're better off using either Unix-domain sockets or IP-domain sockets confined to localhost (the lo0 loopback interface).

Share This Page