2005-11-26 13:19:09 +00:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
|
2010-03-16 20:42:54 +00:00
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
2005-11-26 13:19:09 +00:00
|
|
|
#include <fcntl.h>
|
2010-03-16 20:42:54 +00:00
|
|
|
#include <mqueue.h>
|
2005-11-26 13:19:09 +00:00
|
|
|
#include <signal.h>
|
2010-03-16 20:42:54 +00:00
|
|
|
#include <stdio.h>
|
2005-11-26 13:19:09 +00:00
|
|
|
|
2015-04-28 10:56:59 +00:00
|
|
|
#include "freebsd_test_suite/macros.h"
|
|
|
|
|
2005-11-26 13:19:09 +00:00
|
|
|
#define MQNAME "/mytstqueue1"
|
|
|
|
|
2015-04-11 09:20:20 +00:00
|
|
|
int
|
|
|
|
main(void)
|
2005-11-26 13:19:09 +00:00
|
|
|
{
|
|
|
|
struct mq_attr attr, attr2;
|
|
|
|
struct sigevent sigev;
|
2007-01-06 11:32:15 +00:00
|
|
|
mqd_t mq;
|
2005-11-26 13:19:09 +00:00
|
|
|
int status;
|
|
|
|
|
2015-04-28 10:56:59 +00:00
|
|
|
PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
|
|
|
|
|
2005-11-26 13:19:09 +00:00
|
|
|
attr.mq_maxmsg = 2;
|
|
|
|
attr.mq_msgsize = 100;
|
|
|
|
mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr);
|
2007-01-06 11:32:15 +00:00
|
|
|
if (mq == (mqd_t)-1)
|
2005-11-26 13:19:09 +00:00
|
|
|
err(1, "mq_open");
|
|
|
|
status = mq_unlink(MQNAME);
|
|
|
|
if (status)
|
|
|
|
err(1, "mq_unlink");
|
|
|
|
status = mq_getattr(mq, &attr2);
|
|
|
|
if (status)
|
|
|
|
err(1, "mq_getattr");
|
|
|
|
if (attr.mq_maxmsg != attr2.mq_maxmsg)
|
|
|
|
err(1, "mq_maxmsg changed");
|
|
|
|
if (attr.mq_msgsize != attr2.mq_msgsize)
|
|
|
|
err(1, "mq_msgsize changed");
|
|
|
|
|
|
|
|
sigev.sigev_notify = SIGEV_SIGNAL;
|
|
|
|
sigev.sigev_signo = SIGRTMIN;
|
|
|
|
status = mq_notify(mq, &sigev);
|
|
|
|
if (status)
|
|
|
|
err(1, "mq_notify");
|
|
|
|
status = mq_notify(mq, &sigev);
|
|
|
|
if (status == 0)
|
|
|
|
err(1, "mq_notify 2");
|
|
|
|
else if (errno != EBUSY)
|
|
|
|
err(1, "mq_notify 3");
|
|
|
|
status = mq_notify(mq, NULL);
|
|
|
|
if (status)
|
|
|
|
err(1, "mq_notify 4");
|
|
|
|
status = mq_close(mq);
|
|
|
|
if (status)
|
|
|
|
err(1, "mq_close");
|
|
|
|
return (0);
|
|
|
|
}
|