summaryrefslogtreecommitdiffstats
path: root/man3/mq_notify.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/mq_notify.3')
-rw-r--r--man3/mq_notify.322
1 files changed, 11 insertions, 11 deletions
diff --git a/man3/mq_notify.3 b/man3/mq_notify.3
index 371ae4617..4f8eb3f88 100644
--- a/man3/mq_notify.3
+++ b/man3/mq_notify.3
@@ -210,10 +210,10 @@ queue and then terminates the process.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
+\&
#define handle_error(msg) \e
do { perror(msg); exit(EXIT_FAILURE); } while (0)
-
+\&
static void /* Thread start function */
tfunc(union sigval sv)
{
@@ -221,46 +221,46 @@ tfunc(union sigval sv)
ssize_t nr;
void *buf;
mqd_t mqdes = *((mqd_t *) sv.sival_ptr);
-
+\&
/* Determine max. msg size; allocate buffer to receive msg */
-
+\&
if (mq_getattr(mqdes, &attr) == \-1)
handle_error("mq_getattr");
buf = malloc(attr.mq_msgsize);
if (buf == NULL)
handle_error("malloc");
-
+\&
nr = mq_receive(mqdes, buf, attr.mq_msgsize, NULL);
if (nr == \-1)
handle_error("mq_receive");
-
+\&
printf("Read %zd bytes from MQ\en", nr);
free(buf);
exit(EXIT_SUCCESS); /* Terminate the process */
}
-
+\&
int
main(int argc, char *argv[])
{
mqd_t mqdes;
struct sigevent sev;
-
+\&
if (argc != 2) {
fprintf(stderr, "Usage: %s <mq\-name>\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
mqdes = mq_open(argv[1], O_RDONLY);
if (mqdes == (mqd_t) \-1)
handle_error("mq_open");
-
+\&
sev.sigev_notify = SIGEV_THREAD;
sev.sigev_notify_function = tfunc;
sev.sigev_notify_attributes = NULL;
sev.sigev_value.sival_ptr = &mqdes; /* Arg. to thread func. */
if (mq_notify(mqdes, &sev) == \-1)
handle_error("mq_notify");
-
+\&
pause(); /* Process will be terminated by thread function */
}
.EE