Back to home page

LXR

 
 

    


Warning, /cpukit/posix/src/README.md is written in an unsupported language. File is not indexed.

0001 mqueue
0002 ======
0003 This program should print out the default attribute settings for a 
0004 POSIX message queue.
0005 
0006 ```c
0007 #include <mqueue.h>
0008 #include <stdio.h>
0009 
0010 main()
0011 {
0012   mqd_t mqfd;
0013   struct mq_attr mqstat;
0014   int status;
0015 
0016   /* this should create it */
0017   mqfd = mq_open("myipc",O_WRONLY|O_CREAT,NULL);
0018   if ( (int)mqfd == -1 ) {
0019     perror( "Unable to open message queue" );
0020     exit( 1 );
0021   }
0022 
0023   status = mq_getattr(mqfd, &mqstat);
0024   if ( !status ) {
0025     printf( "mq_maxmsg: %d\n", mqstat.mq_maxmsg );
0026     printf( "mq_msgsize: %d\n", mqstat.mq_msgsize );
0027     printf( "mq_curmsgs: %d\n", mqstat.mq_curmsgs );
0028   } else {
0029     perror( "Unable to get attributes on message queue" );
0030     exit( 1 );
0031   }
0032 
0033   /* this should delete it */
0034   (void) mq_close( mqfd );
0035   exit( 0 );
0036 }
0037 ```