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/man3/sem_wait.3 | |
| 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/man3/sem_wait.3')
| -rw-r--r-- | man/man3/sem_wait.3 | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/man/man3/sem_wait.3 b/man/man3/sem_wait.3 index 2aa68eb345..8b75ea59a6 100644 --- a/man/man3/sem_wait.3 +++ b/man/man3/sem_wait.3 @@ -165,6 +165,7 @@ sem_timedwait() timed out \& .\" SRC BEGIN (sem_wait.c) .EX +#include <err.h> #include <errno.h> #include <semaphore.h> #include <signal.h> @@ -177,9 +178,6 @@ sem_timedwait() timed out \& sem_t sem; \& -#define handle_error(msg) \[rs] - do { perror(msg); exit(EXIT_FAILURE); } while (0) -\& static void handler(int sig) { @@ -204,7 +202,7 @@ main(int argc, char *argv[]) } \& if (sem_init(&sem, 0, 0) == \-1) - handle_error("sem_init"); + err(EXIT_FAILURE, "sem_init"); \& /* Establish SIGALRM handler; set alarm timer using argv[1]. */ \& @@ -212,7 +210,7 @@ main(int argc, char *argv[]) sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGALRM, &sa, NULL) == \-1) - handle_error("sigaction"); + err(EXIT_FAILURE, "sigaction"); \& alarm(atoi(argv[1])); \& @@ -220,7 +218,7 @@ main(int argc, char *argv[]) number of seconds given argv[2]. */ \& if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) - handle_error("clock_gettime"); + err(EXIT_FAILURE, "clock_gettime"); \& ts.tv_sec += atoi(argv[2]); \& |
