xref: /netbsd-src/lib/libc/sys/timer_create.2 (revision 01869ca4d24a86379a68731bf9706a9f0820fe4e)
1*01869ca4Swiz.\"	$NetBSD: timer_create.2,v 1.13 2017/07/03 21:32:50 wiz Exp $
2226b4082Schristos.\"
3226b4082Schristos.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
4226b4082Schristos.\" All rights reserved.
5226b4082Schristos.\"
6226b4082Schristos.\" This code is derived from software contributed to The NetBSD Foundation
7226b4082Schristos.\" by Christos Zoulas.
8226b4082Schristos.\"
9226b4082Schristos.\" Redistribution and use in source and binary forms, with or without
10226b4082Schristos.\" modification, are permitted provided that the following conditions
11226b4082Schristos.\" are met:
12226b4082Schristos.\" 1. Redistributions of source code must retain the above copyright
13226b4082Schristos.\"    notice, this list of conditions and the following disclaimer.
14226b4082Schristos.\" 2. Redistributions in binary form must reproduce the above copyright
15226b4082Schristos.\"    notice, this list of conditions and the following disclaimer in the
16226b4082Schristos.\"    documentation and/or other materials provided with the distribution.
17226b4082Schristos.\"
18226b4082Schristos.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19226b4082Schristos.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20226b4082Schristos.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21226b4082Schristos.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22226b4082Schristos.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23226b4082Schristos.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24226b4082Schristos.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25226b4082Schristos.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26226b4082Schristos.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27226b4082Schristos.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28226b4082Schristos.\" POSSIBILITY OF SUCH DAMAGE.
29226b4082Schristos.\"
3020964028Sjruoho.Dd May 19, 2010
31226b4082Schristos.Dt TIMER_CREATE 2
32226b4082Schristos.Os
33226b4082Schristos.Sh NAME
34226b4082Schristos.Nm timer_create
35226b4082Schristos.Nd create a per-process timer
36226b4082Schristos.Sh LIBRARY
37226b4082Schristos.Lb libc
38226b4082Schristos.Sh SYNOPSIS
39226b4082Schristos.In time.h
40226b4082Schristos.In signal.h
41226b4082Schristos.Ft int
429865e7ffSkleink.Fn timer_create "clockid_t clockid" "struct sigevent * restrict evp" "timer_t * restrict timerid"
43226b4082Schristos.Sh DESCRIPTION
44226b4082SchristosThe
45226b4082Schristos.Fn timer_create
46226b4082Schristosfunction creates a per-process timer using the clock specified in the
47226b4082Schristos.Ar clockid
48226b4082Schristosargument.
49226b4082SchristosIf it succeeds, the
50226b4082Schristos.Fn timer_create
51226b4082Schristosfunction fills in the
52226b4082Schristos.Ar timerid
53ae6d7048Ssnjargument with an id associated with the timer created that can be used by
545a12b706Swizother timer related calls.
555a12b706SwizThe
56226b4082Schristos.Ar clockid
57226b4082Schristosmust be a valid clock id as defined in
581c3412faSjoerg.In time.h .
59226b4082SchristosThe timer is created in a disarmed state.
60226b4082Schristos.Pp
615a12b706SwizAn optional
625a12b706Swiz.Pq non- Ns Dv NULL
6320964028Sjruoho.Em struct sigevent
6420964028Sjruohoargument can be specified by the
65226b4082Schristos.Ar evp
665a12b706Swizargument.
675a12b706SwizIf the
68226b4082Schristos.Ar evp
69226b4082Schristosargument is
70226b4082Schristos.Dv NULL ,
7120964028Sjruohothen
72*01869ca4Swiz.Fa evp->sigev_notify
7320964028Sjruohodefaults to
74c4bdad93Sdrochner.Dv SIGEV_SIGNAL
75226b4082Schristosand
76*01869ca4Swiz.Fa evp->sigev_value
7720964028Sjruohois set to
78226b4082Schristos.Ar timerid .
7920964028SjruohoRefer to
8020964028Sjruoho.Xr sigevent 3
8120964028Sjruohofor more details.
82226b4082Schristos.Sh NOTES
83226b4082SchristosTimers are not inherited after a
84226b4082Schristos.Xr fork 2
85226b4082Schristosand are disarmed and deleted by an
865a12b706Swiz.Xr exec 3 .
87226b4082Schristos.Sh RETURN VALUES
88b9f1052aSkleinkIf successful, the
89226b4082Schristos.Fn timer_create
90b9f1052aSkleinkfunction returns 0, and fills in the
91226b4082Schristos.Ar timerid
92226b4082Schristosargument with the id of the new timer that was created.
93b9f1052aSkleinkOtherwise, it returns \-1, and sets
94b9f1052aSkleink.Dv errno
95b9f1052aSkleinkto indicate the error.
96226b4082Schristos.Sh ERRORS
97226b4082SchristosThe
98226b4082Schristos.Fn timer_create
99226b4082Schristosfunction will fail if:
100226b4082Schristos.Bl -tag -width Er
101226b4082Schristos.It Bq Er EAGAIN
102226b4082SchristosThe system is out of resources to satisfy this request, or the process has
103226b4082Schristoscreated all the timers it is allowed.
104226b4082Schristos.It Bq Er EINVAL
105b9f1052aSkleinkThe argument
106226b4082Schristos.Ar clockid
107b9f1052aSkleinkis not a valid clock id.
1085a12b706Swiz.El
109226b4082Schristos.Sh SEE ALSO
1105a12b706Swiz.Xr clock_getres 2 ,
111226b4082Schristos.Xr clock_gettime 2 ,
112226b4082Schristos.Xr clock_settime 2 ,
113226b4082Schristos.Xr timer_delete 2 ,
114226b4082Schristos.Xr timer_getoverrun 2 ,
1155a12b706Swiz.Xr timer_gettime 2 ,
1163551775cSuwe.Xr timer_settime 2 ,
1173551775cSuwe.Xr sigevent 3
118226b4082Schristos.Sh STANDARDS
119226b4082Schristos.St -p1003.1b-93 ,
120226b4082Schristos.St -p1003.1i-95
121