aboutsummaryrefslogtreecommitdiffstats
path: root/man/man3/mq_notify.3
diff options
context:
space:
mode:
Diffstat (limited to 'man/man3/mq_notify.3')
-rw-r--r--man/man3/mq_notify.314
1 files changed, 6 insertions, 8 deletions
diff --git a/man/man3/mq_notify.3 b/man/man3/mq_notify.3
index 87e5cfe341..cb375a0db0 100644
--- a/man/man3/mq_notify.3
+++ b/man/man3/mq_notify.3
@@ -201,6 +201,7 @@ queue and then terminates the process.
.SS Program source
.\" SRC BEGIN (mq_notify.c)
.EX
+#include <err.h>
#include <mqueue.h>
#include <pthread.h>
#include <signal.h>
@@ -208,9 +209,6 @@ queue and then terminates the process.
#include <stdlib.h>
#include <unistd.h>
\&
-#define handle_error(msg) \[rs]
- do { perror(msg); exit(EXIT_FAILURE); } while (0)
-\&
static void /* Thread start function */
tfunc(union sigval sv)
{
@@ -222,14 +220,14 @@ tfunc(union sigval sv)
/* Determine max. msg size; allocate buffer to receive msg */
\&
if (mq_getattr(mqdes, &attr) == \-1)
- handle_error("mq_getattr");
+ err(EXIT_FAILURE, "mq_getattr");
buf = malloc(attr.mq_msgsize);
if (buf == NULL)
- handle_error("malloc");
+ err(EXIT_FAILURE, "malloc");
\&
nr = mq_receive(mqdes, buf, attr.mq_msgsize, NULL);
if (nr == \-1)
- handle_error("mq_receive");
+ err(EXIT_FAILURE, "mq_receive");
\&
printf("Read %zd bytes from MQ\[rs]n", nr);
free(buf);
@@ -249,14 +247,14 @@ main(int argc, char *argv[])
\&
mqdes = mq_open(argv[1], O_RDONLY);
if (mqdes == (mqd_t) \-1)
- handle_error("mq_open");
+ err(EXIT_FAILURE, "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");
+ err(EXIT_FAILURE, "mq_notify");
\&
pause(); /* Process will be terminated by thread function */
}