2 Copyright (C) 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
35 #include "tst-mqueue.h"
42 volatile int rtmin_cnt;
43 volatile pid_t rtmin_pid;
44 volatile uid_t rtmin_uid;
45 volatile union sigval rtmin_sigval;
48 rtmin_handler (int sig, siginfo_t *info, void *ctx)
53 rtmin_pid = info->si_pid;
54 rtmin_uid = info->si_uid;
55 rtmin_sigval = info->si_value;
58 #define mqsend(q) (mqsend) (q, __LINE__)
60 (mqsend) (mqd_t q, int line)
63 if (mq_send (q, &c, 1, 1) != 0)
65 printf ("mq_send on line %d failed with: %m\n", line);
71 #define mqrecv(q) (mqrecv) (q, __LINE__)
73 (mqrecv) (mqd_t q, int line)
76 ssize_t rets = TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL));
80 printf ("mq_receive on line %d failed with: %m\n", line);
82 printf ("mq_receive on line %d returned %zd != 1\n",
92 pthread_barrier_t *b3;
99 pthread_barrier_t *b3 = ((struct thr_data *)arg)->b3;
100 mqd_t q = ((struct thr_data *)arg)->q;
101 const char *name = ((struct thr_data *)arg)->name;
104 result |= mqrecv (q);
106 (void) pthread_barrier_wait (b3);
108 /* Child verifies SIGRTMIN has not been sent. */
110 (void) pthread_barrier_wait (b3);
112 /* Parent calls mqsend (q), which should trigger notification. */
114 (void) pthread_barrier_wait (b3);
118 puts ("SIGRTMIN signal in child did not arrive");
121 else if (rtmin_pid != getppid ()
122 || rtmin_uid != getuid ()
123 || rtmin_sigval.sival_int != 0xdeadbeef)
125 printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), si_int %d (%d)\n",
126 rtmin_pid, getppid (), rtmin_uid, getuid (),
127 rtmin_sigval.sival_int, 0xdeadbeef);
132 memset (&ev, 0x82, sizeof (ev));
133 ev.sigev_notify = SIGEV_NONE;
134 if (mq_notify (q, &ev) != 0)
136 printf ("mq_notify in thread (q, { SIGEV_NONE }) failed with: %m\n");
140 if (mq_notify (q, NULL) != 0)
142 printf ("mq_notify in thread (q, NULL) failed with: %m\n");
146 result |= mqrecv (q);
148 (void) pthread_barrier_wait (b3);
150 /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
152 (void) pthread_barrier_wait (b3);
154 if (mq_notify (q, NULL) != 0)
156 printf ("second mq_notify in thread (q, NULL) failed with: %m\n");
160 (void) pthread_barrier_wait (b3);
162 /* Parent calls mqsend (q), which should not trigger notification. */
164 (void) pthread_barrier_wait (b3);
166 /* Child verifies SIGRTMIN has not been received. */
167 /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
169 (void) pthread_barrier_wait (b3);
171 mqd_t q4 = mq_open (name, O_RDONLY);
172 if (q4 == (mqd_t) -1)
174 printf ("mq_open in thread failed with: %m\n");
178 if (mq_notify (q4, NULL) != 0)
180 printf ("mq_notify in thread (q4, NULL) failed with: %m\n");
184 if (mq_close (q4) != 0)
186 printf ("mq_close in thread failed with: %m\n");
190 (void) pthread_barrier_wait (b3);
192 /* Parent calls mqsend (q), which should not trigger notification. */
194 (void) pthread_barrier_wait (b3);
196 /* Child verifies SIGRTMIN has not been received. */
197 /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
199 (void) pthread_barrier_wait (b3);
201 mqd_t q5 = mq_open (name, O_WRONLY);
202 if (q5 == (mqd_t) -1)
204 printf ("mq_open O_WRONLY in thread failed with: %m\n");
208 if (mq_notify (q5, NULL) != 0)
210 printf ("mq_notify in thread (q5, NULL) failed with: %m\n");
214 if (mq_close (q5) != 0)
216 printf ("mq_close in thread failed with: %m\n");
220 (void) pthread_barrier_wait (b3);
222 /* Parent calls mqsend (q), which should not trigger notification. */
224 (void) pthread_barrier_wait (b3);
226 /* Child verifies SIGRTMIN has not been received. */
228 return (void *) (long) result;
232 do_child (const char *name, pthread_barrier_t *b2, pthread_barrier_t *b3,
238 memset (&ev, 0x55, sizeof (ev));
239 ev.sigev_notify = SIGEV_SIGNAL;
240 ev.sigev_signo = SIGRTMIN;
241 ev.sigev_value.sival_ptr = &ev;
242 if (mq_notify (q, &ev) == 0)
244 puts ("first mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
247 else if (errno != EBUSY)
249 printf ("first mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
253 (void) pthread_barrier_wait (b2);
255 /* Parent calls mqsend (q), which makes notification available. */
257 (void) pthread_barrier_wait (b2);
261 if (mq_notify (q, &ev) != 0)
263 printf ("second mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
269 puts ("SIGRTMIN signal in child caught too early");
273 (void) pthread_barrier_wait (b2);
275 /* Parent unsuccessfully attempts to mq_notify. */
276 /* Parent calls mqsend (q), which makes notification available
277 and triggers a signal in the child. */
278 /* Parent successfully calls mq_notify SIGEV_SIGNAL. */
280 (void) pthread_barrier_wait (b2);
284 puts ("SIGRTMIN signal in child did not arrive");
287 else if (rtmin_pid != getppid ()
288 || rtmin_uid != getuid ()
289 || rtmin_sigval.sival_ptr != &ev)
291 printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), si_ptr %p (%p)\n",
292 rtmin_pid, getppid (), rtmin_uid, getuid (),
293 rtmin_sigval.sival_ptr, &ev);
297 result |= mqsend (q);
299 (void) pthread_barrier_wait (b2);
301 /* Parent verifies caught SIGRTMIN. */
303 mqd_t q2 = mq_open (name, O_RDWR);
304 if (q2 == (mqd_t) -1)
306 printf ("mq_open in child failed with: %m\n");
310 (void) pthread_barrier_wait (b2);
312 /* Parent mq_open's another mqd_t for the same queue (q3). */
314 memset (&ev, 0x11, sizeof (ev));
315 ev.sigev_notify = SIGEV_SIGNAL;
316 ev.sigev_signo = SIGRTMIN;
317 ev.sigev_value.sival_ptr = &ev;
318 if (mq_notify (q2, &ev) != 0)
320 printf ("mq_notify in child (q2, { SIGEV_SIGNAL }) failed with: %m\n");
324 (void) pthread_barrier_wait (b2);
326 /* Parent unsuccessfully attempts to mq_notify { SIGEV_NONE } on q. */
328 (void) pthread_barrier_wait (b2);
330 if (mq_close (q2) != 0)
332 printf ("mq_close failed: %m\n");
336 (void) pthread_barrier_wait (b2);
338 /* Parent successfully calls mq_notify { SIGEV_NONE } on q3. */
340 (void) pthread_barrier_wait (b2);
342 memset (&ev, 0xbb, sizeof (ev));
343 ev.sigev_notify = SIGEV_SIGNAL;
344 ev.sigev_signo = SIGRTMIN;
345 ev.sigev_value.sival_ptr = &b2;
346 if (mq_notify (q, &ev) == 0)
348 puts ("third mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
351 else if (errno != EBUSY)
353 printf ("third mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
357 (void) pthread_barrier_wait (b2);
359 /* Parent calls mq_close on q3, which makes the queue available again for
362 (void) pthread_barrier_wait (b2);
364 memset (&ev, 0x13, sizeof (ev));
365 ev.sigev_notify = SIGEV_NONE;
366 if (mq_notify (q, &ev) != 0)
368 printf ("mq_notify in child (q, { SIGEV_NONE }) failed with: %m\n");
372 if (mq_notify (q, NULL) != 0)
374 printf ("mq_notify in child (q, NULL) failed with: %m\n");
378 (void) pthread_barrier_wait (b2);
380 struct thr_data thr_data = { .name = name, .b3 = b3, .q = q };
382 int ret = pthread_create (&th, NULL, thr, &thr_data);
386 printf ("pthread_created failed with: %m\n");
390 /* Wait till thr calls mq_receive on the empty queue q and blocks on it. */
393 memset (&ev, 0x5f, sizeof (ev));
394 ev.sigev_notify = SIGEV_SIGNAL;
395 ev.sigev_signo = SIGRTMIN;
396 ev.sigev_value.sival_int = 0xdeadbeef;
397 if (mq_notify (q, &ev) != 0)
399 printf ("fourth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
403 (void) pthread_barrier_wait (b2);
405 /* Parent calls mqsend (q), which should wake up mqrecv (q)
406 in the thread but no notification should be sent. */
408 (void) pthread_barrier_wait (b3);
412 puts ("SIGRTMIN signal caught while thr was blocked on mq_receive");
416 (void) pthread_barrier_wait (b3);
418 /* Parent calls mqsend (q), which should trigger notification. */
420 (void) pthread_barrier_wait (b3);
422 /* Thread verifies SIGRTMIN has been received. */
423 /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now
424 available for registration. */
425 /* Thread calls mq_notify (q, NULL). */
427 (void) pthread_barrier_wait (b3);
429 memset (&ev, 0x6a, sizeof (ev));
430 ev.sigev_notify = SIGEV_SIGNAL;
431 ev.sigev_signo = SIGRTMIN;
432 ev.sigev_value.sival_ptr = do_child;
433 if (mq_notify (q, &ev) != 0)
435 printf ("fifth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
439 (void) pthread_barrier_wait (b3);
441 /* Thread calls mq_notify (q, NULL), which should unregister the above
444 (void) pthread_barrier_wait (b3);
446 /* Parent calls mqsend (q), which should not trigger notification. */
448 (void) pthread_barrier_wait (b3);
452 puts ("SIGRTMIN signal caught while notification has been disabled");
456 memset (&ev, 0x7b, sizeof (ev));
457 ev.sigev_notify = SIGEV_SIGNAL;
458 ev.sigev_signo = SIGRTMIN;
459 ev.sigev_value.sival_ptr = thr;
460 if (mq_notify (q, &ev) != 0)
462 printf ("sixth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
466 (void) pthread_barrier_wait (b3);
468 /* Thread opens a new O_RDONLY mqd_t (q4). */
469 /* Thread calls mq_notify (q4, NULL), which should unregister the above
471 /* Thread calls mq_close (q4). */
473 (void) pthread_barrier_wait (b3);
475 /* Parent calls mqsend (q), which should not trigger notification. */
477 (void) pthread_barrier_wait (b3);
481 puts ("SIGRTMIN signal caught while notification has been disabled");
485 memset (&ev, 0xe1, sizeof (ev));
486 ev.sigev_notify = SIGEV_SIGNAL;
487 ev.sigev_signo = SIGRTMIN;
488 ev.sigev_value.sival_int = 127;
489 if (mq_notify (q, &ev) != 0)
491 printf ("seventh mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
495 (void) pthread_barrier_wait (b3);
497 /* Thread opens a new O_WRONLY mqd_t (q5). */
498 /* Thread calls mq_notify (q5, NULL), which should unregister the above
500 /* Thread calls mq_close (q5). */
502 (void) pthread_barrier_wait (b3);
504 /* Parent calls mqsend (q), which should not trigger notification. */
506 (void) pthread_barrier_wait (b3);
510 puts ("SIGRTMIN signal caught while notification has been disabled");
515 ret = pthread_join (th, &thr_ret);
519 printf ("pthread_join failed: %m\n");
525 if (mq_close (q) != 0)
527 printf ("mq_close failed: %m\n");
534 #define TEST_FUNCTION do_test ()
540 char tmpfname[] = "/tmp/tst-mqueue5-barrier.XXXXXX";
541 int fd = mkstemp (tmpfname);
544 printf ("cannot open temporary file: %m\n");
548 /* Make sure it is always removed. */
551 /* Create one page of data. */
552 size_t ps = sysconf (_SC_PAGESIZE);
554 memset (data, '\0', ps);
556 /* Write the data to the file. */
557 if (write (fd, data, ps) != (ssize_t) ps)
559 puts ("short write");
563 void *mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
564 if (mem == MAP_FAILED)
566 printf ("mmap failed: %m\n");
570 pthread_barrier_t *b2;
571 b2 = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
572 & ~(__alignof (pthread_barrier_t) - 1));
574 pthread_barrier_t *b3;
577 pthread_barrierattr_t a;
578 if (pthread_barrierattr_init (&a) != 0)
580 puts ("barrierattr_init failed");
584 if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
586 puts ("barrierattr_setpshared failed, could not test");
590 if (pthread_barrier_init (b2, &a, 2) != 0)
592 puts ("barrier_init failed");
596 if (pthread_barrier_init (b3, &a, 3) != 0)
598 puts ("barrier_init failed");
602 if (pthread_barrierattr_destroy (&a) != 0)
604 puts ("barrierattr_destroy failed");
608 char name[sizeof "/tst-mqueue5-" + sizeof (pid_t) * 3];
609 snprintf (name, sizeof (name), "/tst-mqueue5-%u", getpid ());
611 struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
612 mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
616 printf ("mq_open failed with: %m\n");
623 memset (&ev, 0xaa, sizeof (ev));
624 ev.sigev_notify = SIGEV_NONE;
625 if (mq_notify (q, &ev) != 0)
627 printf ("mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
631 if (mq_notify (q, &ev) == 0)
633 puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
636 else if (errno != EBUSY)
638 printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
642 result |= mqsend (q);
644 if (mq_notify (q, &ev) != 0)
646 printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
650 result |= mqrecv (q);
652 if (mq_notify (q, NULL) != 0)
654 printf ("mq_notify (q, NULL) failed with: %m\n");
658 if (mq_notify (q, NULL) != 0)
660 /* Implementation-defined behaviour, so don't fail,
662 printf ("second mq_notify (q, NULL) failed with: %m\n");
665 struct sigaction sa = { .sa_sigaction = rtmin_handler,
666 .sa_flags = SA_SIGINFO };
667 sigemptyset (&sa.sa_mask);
668 sigaction (SIGRTMIN, &sa, NULL);
670 memset (&ev, 0x55, sizeof (ev));
671 ev.sigev_notify = SIGEV_SIGNAL;
672 ev.sigev_signo = SIGRTMIN;
673 ev.sigev_value.sival_int = 26;
674 if (mq_notify (q, &ev) != 0)
676 printf ("mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
680 ev.sigev_value.sival_ptr = &ev;
681 if (mq_notify (q, &ev) == 0)
683 puts ("second mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
686 else if (errno != EBUSY)
688 printf ("second mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
694 puts ("SIGRTMIN signal caught too early");
698 result |= mqsend (q);
702 puts ("SIGRTMIN signal did not arrive");
705 else if (rtmin_pid != getpid ()
706 || rtmin_uid != getuid ()
707 || rtmin_sigval.sival_int != 26)
709 printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), si_int %d (26)\n",
710 rtmin_pid, getpid (), rtmin_uid, getuid (),
711 rtmin_sigval.sival_int);
715 ev.sigev_value.sival_int = 75;
716 if (mq_notify (q, &ev) != 0)
718 printf ("third mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
722 result |= mqrecv (q);
724 if (mq_notify (q, NULL) != 0)
726 printf ("mq_notify (q, NULL) failed with: %m\n");
730 memset (&ev, 0x33, sizeof (ev));
731 ev.sigev_notify = SIGEV_NONE;
732 if (mq_notify (q, &ev) != 0)
734 printf ("fourth mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
741 printf ("fork () failed: %m\n");
747 do_child (name, b2, b3, q);
749 /* Child unsuccessfully attempts to mq_notify. */
751 (void) pthread_barrier_wait (b2);
753 result |= mqsend (q);
755 (void) pthread_barrier_wait (b2);
757 /* Child successfully calls mq_notify SIGEV_SIGNAL now. */
759 result |= mqrecv (q);
761 (void) pthread_barrier_wait (b2);
763 memset (&ev, 0xbb, sizeof (ev));
764 ev.sigev_notify = SIGEV_SIGNAL;
765 ev.sigev_signo = SIGRTMIN;
766 ev.sigev_value.sival_int = 15;
767 if (mq_notify (q, &ev) == 0)
769 puts ("fourth mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
772 else if (errno != EBUSY)
774 printf ("fourth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
778 result |= mqsend (q);
780 if (mq_notify (q, &ev) != 0)
782 printf ("fifth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
788 puts ("SIGRTMIN signal caught too early");
792 result |= mqrecv (q);
794 (void) pthread_barrier_wait (b2);
796 /* Child verifies caught SIGRTMIN signal. */
797 /* Child calls mq_send (q) which triggers SIGRTMIN signal here. */
799 (void) pthread_barrier_wait (b2);
801 /* Child mq_open's another mqd_t for the same queue (q2). */
805 puts ("SIGRTMIN signal did not arrive");
808 else if (rtmin_pid != pid
809 || rtmin_uid != getuid ()
810 || rtmin_sigval.sival_int != 15)
812 printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), si_int %d (15)\n",
813 rtmin_pid, pid, rtmin_uid, getuid (),
814 rtmin_sigval.sival_int);
818 result |= mqrecv (q);
820 (void) pthread_barrier_wait (b2);
822 /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q2. */
824 (void) pthread_barrier_wait (b2);
826 memset (&ev, 0xbb, sizeof (ev));
827 ev.sigev_notify = SIGEV_NONE;
828 if (mq_notify (q, &ev) == 0)
830 puts ("fifth mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
833 else if (errno != EBUSY)
835 printf ("fifth mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
839 (void) pthread_barrier_wait (b2);
841 /* Child calls mq_close on q2, which makes the queue available again for
844 mqd_t q3 = mq_open (name, O_RDWR);
845 if (q3 == (mqd_t) -1)
847 printf ("mq_open q3 in parent failed with: %m\n");
851 (void) pthread_barrier_wait (b2);
853 memset (&ev, 0x12, sizeof (ev));
854 ev.sigev_notify = SIGEV_NONE;
855 if (mq_notify (q3, &ev) != 0)
857 printf ("mq_notify (q3, { SIGEV_NONE }) failed with: %m\n");
861 (void) pthread_barrier_wait (b2);
863 /* Child unsuccessfully attempts to mq_notify { SIGEV_SIGNAL } on q. */
865 (void) pthread_barrier_wait (b2);
867 if (mq_close (q3) != 0)
869 printf ("mq_close failed: %m\n");
873 (void) pthread_barrier_wait (b2);
875 /* Child successfully calls mq_notify { SIGEV_NONE } on q. */
876 /* Child successfully calls mq_notify NULL on q. */
878 (void) pthread_barrier_wait (b2);
880 /* Child creates new thread. */
881 /* Thread blocks on mqrecv (q). */
882 /* Child sleeps for 1sec so that thread has time to reach that point. */
883 /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q. */
885 (void) pthread_barrier_wait (b2);
887 result |= mqsend (q);
889 (void) pthread_barrier_wait (b3);
891 /* Child verifies SIGRTMIN has not been sent. */
893 (void) pthread_barrier_wait (b3);
895 result |= mqsend (q);
897 (void) pthread_barrier_wait (b3);
899 /* Thread verifies SIGRTMIN has been caught. */
900 /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now
901 available for registration. */
902 /* Thread calls mq_notify (q, NULL). */
904 (void) pthread_barrier_wait (b3);
906 /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
908 (void) pthread_barrier_wait (b3);
910 /* Thread calls mq_notify (q, NULL). */
912 (void) pthread_barrier_wait (b3);
914 result |= mqsend (q);
915 result |= mqrecv (q);
917 (void) pthread_barrier_wait (b3);
919 /* Child verifies SIGRTMIN has not been sent. */
920 /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
922 (void) pthread_barrier_wait (b3);
924 /* Thread opens a new O_RDONLY mqd_t (q4). */
925 /* Thread calls mq_notify (q4, NULL). */
926 /* Thread calls mq_close (q4). */
928 (void) pthread_barrier_wait (b3);
930 result |= mqsend (q);
931 result |= mqrecv (q);
933 (void) pthread_barrier_wait (b3);
935 /* Child verifies SIGRTMIN has not been sent. */
936 /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
938 (void) pthread_barrier_wait (b3);
940 /* Thread opens a new O_WRONLY mqd_t (q5). */
941 /* Thread calls mq_notify (q5, NULL). */
942 /* Thread calls mq_close (q5). */
944 (void) pthread_barrier_wait (b3);
946 result |= mqsend (q);
947 result |= mqrecv (q);
949 (void) pthread_barrier_wait (b3);
951 /* Child verifies SIGRTMIN has not been sent. */
954 if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
956 puts ("waitpid failed");
960 else if (!WIFEXITED (status) || WEXITSTATUS (status))
962 printf ("child failed with status %d\n", status);
966 if (mq_unlink (name) != 0)
968 printf ("mq_unlink failed: %m\n");
972 if (mq_close (q) != 0)
974 printf ("mq_close failed: %m\n");
978 if (mq_notify (q, NULL) == 0)
980 puts ("mq_notify on closed mqd_t unexpectedly succeeded");
983 else if (errno != EBADF)
985 printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
989 memset (&ev, 0x55, sizeof (ev));
990 ev.sigev_notify = SIGEV_NONE;
991 if (mq_notify (q, &ev) == 0)
993 puts ("mq_notify on closed mqd_t unexpectedly succeeded");
996 else if (errno != EBADF)
998 printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
1005 # define TEST_FUNCTION 0
1008 #include "../test-skeleton.c"