source: rtems/cpukit/posix/src/README.mqueue @ d9f6165

4.104.114.84.95
Last change on this file since d9f6165 was d9f6165, checked in by Joel Sherrill <joel.sherrill@…>, on 01/12/01 at 13:34:24

2001-01-12 Joel Sherrill <joel@…>

  • src/README.mqueue: Enhanced example.
  • Property mode set to 100644
File size: 755 bytes
Line 
1#
2#  $Id$
3#
4
5This program should print out the default attribute settings for a
6POSIX message queue.
7
8#include <mqueue.h>
9#include <stdio.h>
10
11main()
12{
13  mqd_t mqfd;
14  struct mq_attr mqstat;
15  int status;
16
17  /* this should create it */
18  mqfd = mq_open("myipc",O_WRONLY|O_CREAT,NULL);
19  if ( (int)mqfd == -1 ) {
20    perror( "Unable to open message queue" );
21    exit( 1 );
22  }
23
24  status = mq_getattr(mqfd, &mqstat);
25  if ( !status ) {
26    printf( "mq_maxmsg: %d\n", mqstat.mq_maxmsg );
27    printf( "mq_msgsize: %d\n", mqstat.mq_msgsize );
28    printf( "mq_curmsgs: %d\n", mqstat.mq_curmsgs );
29  } else {
30    perror( "Unable to get attributes on message queue" );
31    exit( 1 );
32  }
33
34  /* this should delete it */
35  (void) mq_close( mqfd );
36  exit( 0 );
37}
38
Note: See TracBrowser for help on using the repository browser.