]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man2/timer_create.2
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man2 / timer_create.2
index 57f42019ee9d8b54b5593f94450913e085b4da0a..345cfd70c68a2b7723b1c38713e711102cba1c7c 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
 .\"
-.TH TIMER_CREATE 2 (date) "Linux man-pages (unreleased)"
+.TH timer_create 2 (date) "Linux man-pages (unreleased)"
 .SH NAME
 timer_create \- create a POSIX per-process timer
 .SH LIBRARY
@@ -13,16 +13,17 @@ Real-time library
 .nf
 .BR "#include <signal.h>" "           /* Definition of " SIGEV_* " constants */"
 .B  #include <time.h>
-.PP
-.BI "int timer_create(clockid_t " clockid ", struct sigevent *restrict " sevp ,
+.P
+.BI "int timer_create(clockid_t " clockid ,
+.BI "                 struct sigevent *_Nullable restrict " sevp ,
 .BI "                 timer_t *restrict " timerid );
 .fi
-.PP
+.P
 .RS -4
 Feature Test Macro Requirements for glibc (see
 .BR feature_test_macros (7)):
 .RE
-.PP
+.P
 .BR timer_create ():
 .nf
     _POSIX_C_SOURCE >= 199309L
@@ -35,7 +36,7 @@ The ID of the new timer is returned in the buffer pointed to by
 which must be a non-null pointer.
 This ID is unique within the process, until the timer is deleted.
 The new timer is initially disarmed.
-.PP
+.P
 The
 .I clockid
 argument specifies the clock that the new timer uses to measure time.
@@ -49,7 +50,7 @@ A nonsettable monotonically increasing clock that measures time
 from some unspecified point in the past that does not change
 after system startup.
 .\" Note: the CLOCK_MONOTONIC_RAW clock added for clock_gettime()
-.\" in 2.6.28 is not supported for POSIX timers -- mtk, Feb 2009
+.\" in Linux 2.6.28 is not supported for POSIX timers -- mtk, Feb 2009
 .TP
 .BR CLOCK_PROCESS_CPUTIME_ID " (since Linux 2.6.12)"
 A clock that measures (user and system) CPU time consumed by
@@ -58,7 +59,7 @@ A clock that measures (user and system) CPU time consumed by
 .BR CLOCK_THREAD_CPUTIME_ID " (since Linux 2.6.12)"
 A clock that measures (user and system) CPU time consumed by
 the calling thread.
-.\" The CLOCK_MONOTONIC_RAW that was added in 2.6.28 can't be used
+.\" The CLOCK_MONOTONIC_RAW that was added in Linux 2.6.28 can't be used
 .\" to create a timer -- mtk, Feb 2009
 .TP
 .BR CLOCK_BOOTTIME " (Since Linux 2.6.39)"
@@ -96,11 +97,11 @@ capability in order to set a timer against this clock.
 .TP
 .BR CLOCK_TAI " (since Linux 3.10)"
 A system-wide clock derived from wall-clock time but ignoring leap seconds.
-.PP
+.P
 See
 .BR clock_getres (2)
 for some further details on the above clocks.
-.PP
+.P
 As well as the above values,
 .I clockid
 can be specified as the
@@ -109,7 +110,7 @@ returned by a call to
 .BR clock_getcpuclockid (3)
 or
 .BR pthread_getcpuclockid (3).
-.PP
+.P
 The
 .I sevp
 argument points to a
@@ -117,8 +118,8 @@ argument points to a
 structure that specifies how the caller
 should be notified when the timer expires.
 For the definition and general details of this structure, see
-.BR sigevent (7).
-.PP
+.BR sigevent (3type).
+.P
 The
 .I sevp.sigev_notify
 field can have the following values:
@@ -133,7 +134,7 @@ Upon timer expiration, generate the signal
 .I sigev_signo
 for the process.
 See
-.BR sigevent (7)
+.BR sigevent (3type)
 for general details.
 The
 .I si_code
@@ -151,7 +152,7 @@ Upon timer expiration, invoke
 .I sigev_notify_function
 as if it were the start function of a new thread.
 See
-.BR sigevent (7)
+.BR sigevent (3type)
 for details.
 .TP
 .BR SIGEV_THREAD_ID " (Linux-specific)"
@@ -167,7 +168,7 @@ field specifies a kernel thread ID, that is, the value returned by
 or
 .BR gettid (2).
 This flag is intended only for use by threading libraries.
-.PP
+.P
 Specifying
 .I sevp
 as NULL is equivalent to specifying a pointer to a
@@ -221,18 +222,60 @@ but the caller did not have the
 .B CAP_WAKE_ALARM
 capability.
 .SH VERSIONS
-This system call is available since Linux 2.6.
+.SS C library/kernel differences
+Part of the implementation of the POSIX timers API is provided by glibc.
+.\" See nptl/sysdeps/unix/sysv/linux/timer_create.c
+In particular:
+.IP \[bu] 3
+Much of the functionality for
+.B SIGEV_THREAD
+is implemented within glibc, rather than the kernel.
+(This is necessarily so,
+since the thread involved in handling the notification is one
+that must be managed by the C library POSIX threads implementation.)
+Although the notification delivered to the process is via a thread,
+internally the NPTL implementation uses a
+.I sigev_notify
+value of
+.B SIGEV_THREAD_ID
+along with a real-time signal that is reserved by the implementation (see
+.BR nptl (7)).
+.IP \[bu]
+The implementation of the default case where
+.I evp
+is NULL is handled inside glibc,
+which invokes the underlying system call with a suitably populated
+.I sigevent
+structure.
+.IP \[bu]
+The timer IDs presented at user level are maintained by glibc,
+which maps these IDs to the timer IDs employed by the kernel.
+.\" See the glibc source file kernel-posix-timers.h for the structure
+.\" that glibc uses to map user-space timer IDs to kernel timer IDs
+.\" The kernel-level timer ID is exposed via siginfo.si_tid.
 .SH STANDARDS
-POSIX.1-2001, POSIX.1-2008.
+POSIX.1-2008.
+.SH HISTORY
+Linux 2.6.
+POSIX.1-2001.
+.P
+Prior to Linux 2.6,
+glibc provided an incomplete user-space implementation
+.RB ( CLOCK_REALTIME
+timers only) using POSIX threads,
+and before glibc 2.17,
+.\" glibc commit 93a78ac437ba44f493333d7e2a4b0249839ce460
+the implementation falls back to this technique on systems
+running kernels older than Linux 2.6.
 .SH NOTES
 A program may create multiple interval timers using
 .BR timer_create ().
-.PP
+.P
 Timers are not inherited by the child of a
 .BR fork (2),
 and are disarmed and deleted during an
 .BR execve (2).
-.PP
+.P
 The kernel preallocates a "queued real-time signal"
 for each timer created using
 .BR timer_create ().
@@ -240,7 +283,7 @@ Consequently, the number of timers is limited by the
 .B RLIMIT_SIGPENDING
 resource limit (see
 .BR setrlimit (2)).
-.PP
+.P
 The timers created by
 .BR timer_create ()
 are commonly known as "POSIX (interval) timers".
@@ -261,7 +304,7 @@ Return the overrun count for the last timer expiration.
 .TP
 .BR timer_delete (2)
 Disarm and delete a timer.
-.PP
+.P
 Since Linux 3.10, the
 .IR /proc/ pid /timers
 file can be used to list the POSIX timers for the process with PID
@@ -269,55 +312,13 @@ file can be used to list the POSIX timers for the process with PID
 See
 .BR proc (5)
 for further information.
-.PP
+.P
 Since Linux 4.10,
 .\" baa73d9e478ff32d62f3f9422822b59dd9a95a21
 support for POSIX timers is a configurable option that is enabled by default.
 Kernel support can be disabled via the
 .B CONFIG_POSIX_TIMERS
 option.
-.\"
-.SS C library/kernel differences
-Part of the implementation of the POSIX timers API is provided by glibc.
-.\" See nptl/sysdeps/unix/sysv/linux/timer_create.c
-In particular:
-.IP \(bu 3
-Much of the functionality for
-.B SIGEV_THREAD
-is implemented within glibc, rather than the kernel.
-(This is necessarily so,
-since the thread involved in handling the notification is one
-that must be managed by the C library POSIX threads implementation.)
-Although the notification delivered to the process is via a thread,
-internally the NPTL implementation uses a
-.I sigev_notify
-value of
-.B SIGEV_THREAD_ID
-along with a real-time signal that is reserved by the implementation (see
-.BR nptl (7)).
-.IP \(bu
-The implementation of the default case where
-.I evp
-is NULL is handled inside glibc,
-which invokes the underlying system call with a suitably populated
-.I sigevent
-structure.
-.IP \(bu
-The timer IDs presented at user level are maintained by glibc,
-which maps these IDs to the timer IDs employed by the kernel.
-.\" See the glibc source file kernel-posix-timers.h for the structure
-.\" that glibc uses to map user-space timer IDs to kernel timer IDs
-.\" The kernel-level timer ID is exposed via siginfo.si_tid.
-.PP
-The POSIX timers system calls first appeared in Linux 2.6.
-Prior to this,
-glibc provided an incomplete user-space implementation
-.RB ( CLOCK_REALTIME
-timers only) using POSIX threads,
-and in glibc versions before 2.17,
-.\" glibc commit 93a78ac437ba44f493333d7e2a4b0249839ce460
-the implementation falls back to this technique on systems
-running pre-2.6 Linux kernels.
 .SH EXAMPLES
 The program below takes two arguments: a sleep period in seconds,
 and a timer frequency in nanoseconds.
@@ -330,12 +331,12 @@ Assuming that the timer expired at least once while the program slept,
 the signal handler will be invoked,
 and the handler displays some information about the timer notification.
 The program terminates after one invocation of the signal handler.
-.PP
+.P
 In the following example run, the program sleeps for 1 second,
 after creating a timer that has a frequency of 100 nanoseconds.
 By the time the signal is unblocked and delivered,
 there have been around ten million overruns.
-.PP
+.P
 .in +4n
 .EX
 $ \fB./a.out 1 100\fP
@@ -359,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)
 {
@@ -392,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[])
 {
@@ -407,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
@@ -481,6 +482,6 @@ main(int argc, char *argv[])
 .BR clock_getcpuclockid (3),
 .BR pthread_getcpuclockid (3),
 .BR pthreads (7),
-.BR sigevent (7),
+.BR sigevent (3type),
 .BR signal (7),
 .BR time (7)