/* mqgetatr.c */ /* Get attributes of message queue */ /* To compile: cc mqgetatr.c -lposix4 */ #include #include struct mq_attr mqattr; main( int argc, char **argv) { mqd_t mq; int rc; unsigned int priority; mq = mq_open("/mq.jmw", O_RDONLY, 0700, NULL); printf("mq = %p \n", mq); rc = mq_getattr(mq, &mqattr); if (rc == -1) { printf("Error was: \"%s\"",strerror(errno)); exit(1); } printf("%d %d %d %d \n", mqattr.mq_flags, mqattr.mq_maxmsg, mqattr.mq_msgsize, mqattr.mq_curmsgs); }