diff options
| author | Alejandro Colomar <alx@kernel.org> | 2025-08-19 17:48:50 +0200 |
|---|---|---|
| committer | Alejandro Colomar <alx@kernel.org> | 2025-08-20 18:14:03 +0200 |
| commit | 0e7a39804a3c017a209117fc2243c6cbb543dede (patch) | |
| tree | 91e0b287d8b826d668c3d8118347f07cc8b8964a /man/man2/timer_create.2 | |
| parent | e2d3f14fe40ad90a1fedf0fcd27e6cc896c49a7a (diff) | |
| download | man-pages-0e7a39804a3c.tar.gz | |
man/: EXAMPLES: Use err(3) and errc(3bsd) instead of similar macros
These functions are quite portable. And if one doesn't have them for
some reason (but libbsd has been ported to many systems), one can write
them easily as macros, anyway.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'man/man2/timer_create.2')
| -rw-r--r-- | man/man2/timer_create.2 | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/man/man2/timer_create.2 b/man/man2/timer_create.2 index 287d7bda4a..90ed35ef85 100644 --- a/man/man2/timer_create.2 +++ b/man/man2/timer_create.2 @@ -353,6 +353,7 @@ Caught signal 34 \& .\" SRC BEGIN (timer_create.c) .EX +#include <err.h> #include <signal.h> #include <stdint.h> #include <stdio.h> @@ -363,9 +364,6 @@ Caught signal 34 #define CLOCKID CLOCK_REALTIME #define SIG SIGRTMIN \& -#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \[rs] - } while (0) -\& static void print_siginfo(siginfo_t *si) { @@ -379,9 +377,9 @@ print_siginfo(siginfo_t *si) \& or = timer_getoverrun(*tidp); if (or == \-1) - errExit("timer_getoverrun"); - else - printf(" overrun count = %d\[rs]n", or); + err(EXIT_FAILURE, "timer_getoverrun"); +\& + printf(" overrun count = %d\[rs]n", or); } \& static void @@ -421,7 +419,7 @@ main(int argc, char *argv[]) sa.sa_sigaction = handler; sigemptyset(&sa.sa_mask); if (sigaction(SIG, &sa, NULL) == \-1) - errExit("sigaction"); + err(EXIT_FAILURE, "sigaction"); \& /* Block timer signal temporarily. */ \& @@ -429,7 +427,7 @@ main(int argc, char *argv[]) sigemptyset(&mask); sigaddset(&mask, SIG); if (sigprocmask(SIG_SETMASK, &mask, NULL) == \-1) - errExit("sigprocmask"); + err(EXIT_FAILURE, "sigprocmask"); \& /* Create the timer. */ \& @@ -437,7 +435,7 @@ main(int argc, char *argv[]) sev.sigev_signo = SIG; sev.sigev_value.sival_ptr = &timerid; if (timer_create(CLOCKID, &sev, &timerid) == \-1) - errExit("timer_create"); + err(EXIT_FAILURE, "timer_create"); \& printf("timer ID is %#jx\[rs]n", (uintmax_t) timerid); \& @@ -450,7 +448,7 @@ main(int argc, char *argv[]) its.it_interval.tv_nsec = its.it_value.tv_nsec; \& if (timer_settime(timerid, 0, &its, NULL) == \-1) - errExit("timer_settime"); + err(EXIT_FAILURE, "timer_settime"); \& /* Sleep for a while; meanwhile, the timer may expire multiple times. */ @@ -463,7 +461,7 @@ main(int argc, char *argv[]) \& printf("Unblocking signal %d\[rs]n", SIG); if (sigprocmask(SIG_UNBLOCK, &mask, NULL) == \-1) - errExit("sigprocmask"); + err(EXIT_FAILURE, "sigprocmask"); \& exit(EXIT_SUCCESS); } |
