1 /* $FreeBSD$ */ 2 3 #include <err.h> 4 #include <errno.h> 5 #include <fcntl.h> 6 #include <mqueue.h> 7 #include <signal.h> 8 #include <stdio.h> 9 10 #include "freebsd_test_suite/macros.h" 11 12 #define MQNAME "/mytstqueue1" 13 14 int 15 main(void) 16 { 17 struct mq_attr attr, attr2; 18 struct sigevent sigev; 19 mqd_t mq; 20 int status; 21 22 PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0); 23 24 attr.mq_maxmsg = 2; 25 attr.mq_msgsize = 100; 26 mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); 27 if (mq == (mqd_t)-1) 28 err(1, "mq_open"); 29 status = mq_unlink(MQNAME); 30 if (status) 31 err(1, "mq_unlink"); 32 status = mq_getattr(mq, &attr2); 33 if (status) 34 err(1, "mq_getattr"); 35 if (attr.mq_maxmsg != attr2.mq_maxmsg) 36 err(1, "mq_maxmsg changed"); 37 if (attr.mq_msgsize != attr2.mq_msgsize) 38 err(1, "mq_msgsize changed"); 39 40 sigev.sigev_notify = SIGEV_SIGNAL; 41 sigev.sigev_signo = SIGRTMIN; 42 status = mq_notify(mq, &sigev); 43 if (status) 44 err(1, "mq_notify"); 45 status = mq_notify(mq, &sigev); 46 if (status == 0) 47 err(1, "mq_notify 2"); 48 else if (errno != EBUSY) 49 err(1, "mq_notify 3"); 50 status = mq_notify(mq, NULL); 51 if (status) 52 err(1, "mq_notify 4"); 53 status = mq_close(mq); 54 if (status) 55 err(1, "mq_close"); 56 return (0); 57 } 58