Listing 1

int msqid;              /* Message queue identifier */
key_t key=0x1024;       /* Name of message queue    */

/* Obtain a message queue identifier. If the
 * message queue doesn't exist, create it.
*/
if ((msqid=msgget(key, 0660 | IPC_CREAT)) == -1) {
   /* The perror(3C) function prints the
    * text of the error number contained
    * in the external integer errno.
   */
     perror("msgget() failed: ");
     return(-1);
}