aboutsummaryrefslogtreecommitdiffstats
path: root/man2/timer_create.2
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2023-05-03 00:48:14 +0200
committerAlejandro Colomar <alx@kernel.org>2023-05-03 00:48:22 +0200
commitfe5dba139dc089eae4061fdc17f087e71f48b198 (patch)
tree54af56b1b0138bde9a21e99372ab68ce4d64564a /man2/timer_create.2
parent5a0d9ed151e6449d978fabdd654cacc17b20a235 (diff)
downloadman-pages-fe5dba139dc089eae4061fdc17f087e71f48b198.tar.gz
man*/, man.ignore.grep: srcfix; warn about blank lines
- Use the dummy character to avoid warnings in examples. - Re-enable the warning. Suggested-by: "G. Branden Robinson" <g.branden.robinson@gmail.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'man2/timer_create.2')
-rw-r--r--man2/timer_create.250
1 files changed, 25 insertions, 25 deletions
diff --git a/man2/timer_create.2 b/man2/timer_create.2
index ba5ad78fb3..a3987bb1eb 100644
--- a/man2/timer_create.2
+++ b/man2/timer_create.2
@@ -360,31 +360,31 @@ Caught signal 34
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
-
+\&
#define CLOCKID CLOCK_REALTIME
#define SIG SIGRTMIN
-
+\&
#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \e
} while (0)
-
+\&
static void
print_siginfo(siginfo_t *si)
{
int or;
timer_t *tidp;
-
+\&
tidp = si\->si_value.sival_ptr;
-
+\&
printf(" sival_ptr = %p; ", si\->si_value.sival_ptr);
printf(" *sival_ptr = %#jx\en", (uintmax_t) *tidp);
-
+\&
or = timer_getoverrun(*tidp);
if (or == \-1)
errExit("timer_getoverrun");
else
printf(" overrun count = %d\en", or);
}
-
+\&
static void
handler(int sig, siginfo_t *si, void *uc)
{
@@ -393,12 +393,12 @@ handler(int sig, siginfo_t *si, void *uc)
printf() is not async\-signal\-safe; see signal\-safety(7).
Nevertheless, we use printf() here as a simple way of
showing that the handler was called. */
-
+\&
printf("Caught signal %d\en", sig);
print_siginfo(si);
signal(sig, SIG_IGN);
}
-
+\&
int
main(int argc, char *argv[])
{
@@ -408,64 +408,64 @@ main(int argc, char *argv[])
struct sigevent sev;
struct sigaction sa;
struct itimerspec its;
-
+\&
if (argc != 3) {
fprintf(stderr, "Usage: %s <sleep\-secs> <freq\-nanosecs>\en",
argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
/* Establish handler for timer signal. */
-
+\&
printf("Establishing handler for signal %d\en", SIG);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = handler;
sigemptyset(&sa.sa_mask);
if (sigaction(SIG, &sa, NULL) == \-1)
errExit("sigaction");
-
+\&
/* Block timer signal temporarily. */
-
+\&
printf("Blocking signal %d\en", SIG);
sigemptyset(&mask);
sigaddset(&mask, SIG);
if (sigprocmask(SIG_SETMASK, &mask, NULL) == \-1)
errExit("sigprocmask");
-
+\&
/* Create the timer. */
-
+\&
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = SIG;
sev.sigev_value.sival_ptr = &timerid;
if (timer_create(CLOCKID, &sev, &timerid) == \-1)
errExit("timer_create");
-
+\&
printf("timer ID is %#jx\en", (uintmax_t) timerid);
-
+\&
/* Start the timer. */
-
+\&
freq_nanosecs = atoll(argv[2]);
its.it_value.tv_sec = freq_nanosecs / 1000000000;
its.it_value.tv_nsec = freq_nanosecs % 1000000000;
its.it_interval.tv_sec = its.it_value.tv_sec;
its.it_interval.tv_nsec = its.it_value.tv_nsec;
-
+\&
if (timer_settime(timerid, 0, &its, NULL) == \-1)
errExit("timer_settime");
-
+\&
/* Sleep for a while; meanwhile, the timer may expire
multiple times. */
-
+\&
printf("Sleeping for %d seconds\en", atoi(argv[1]));
sleep(atoi(argv[1]));
-
+\&
/* Unlock the timer signal, so that timer notification
can be delivered. */
-
+\&
printf("Unblocking signal %d\en", SIG);
if (sigprocmask(SIG_UNBLOCK, &mask, NULL) == \-1)
errExit("sigprocmask");
-
+\&
exit(EXIT_SUCCESS);
}
.EE