xref: /freebsd/lib/libc/gen/alarm.3 (revision dc36d6f9bb1753f3808552f3afd30eda9a7b206a)
158f0484fSRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993, 1994
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
558f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
658f0484fSRodney W. Grimes.\" are met:
758f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
858f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
958f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1058f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1158f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
1358f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
1458f0484fSRodney W. Grimes.\"    without specific prior written permission.
1558f0484fSRodney W. Grimes.\"
1658f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1758f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1858f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1958f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2058f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2158f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2258f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2358f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2458f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2558f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2658f0484fSRodney W. Grimes.\" SUCH DAMAGE.
2758f0484fSRodney W. Grimes.\"
28*4b7f35dbSGordon Bergling.Dd April 2, 2022
2958f0484fSRodney W. Grimes.Dt ALARM 3
30a307d598SRuslan Ermilov.Os
3158f0484fSRodney W. Grimes.Sh NAME
3258f0484fSRodney W. Grimes.Nm alarm
3358f0484fSRodney W. Grimes.Nd set signal timer alarm
3425bb73e0SAlexey Zelkin.Sh LIBRARY
3525bb73e0SAlexey Zelkin.Lb libc
3658f0484fSRodney W. Grimes.Sh SYNOPSIS
3732eef9aeSRuslan Ermilov.In unistd.h
38b4176c89SMike Pritchard.Ft unsigned int
39b4176c89SMike Pritchard.Fn alarm "unsigned int seconds"
4058f0484fSRodney W. Grimes.Sh DESCRIPTION
4158f0484fSRodney W. Grimes.Bf -symbolic
426575e6daSRuslan ErmilovThis interface is made obsolete by
436575e6daSRuslan Ermilov.Xr setitimer 2 .
4458f0484fSRodney W. Grimes.Ef
4558f0484fSRodney W. Grimes.Pp
4658f0484fSRodney W. GrimesThe
4758f0484fSRodney W. Grimes.Fn alarm
48b4176c89SMike Pritchardfunction sets a timer to deliver the signal
49b4176c89SMike Pritchard.Dv SIGALRM
50b4176c89SMike Pritchardto the calling process after the specified number of
51b4176c89SMike Pritchard.Fa seconds .
52b4176c89SMike PritchardIf an alarm has already been set with
5358f0484fSRodney W. Grimes.Fn alarm
54b4176c89SMike Pritchardbut has not been delivered, another call to
5558f0484fSRodney W. Grimes.Fn alarm
5658f0484fSRodney W. Grimeswill supersede the prior call.
5758f0484fSRodney W. GrimesThe request
5858f0484fSRodney W. Grimes.Fn alarm "0"
5958f0484fSRodney W. Grimesvoids the current
60067fe639SAndrey A. Chernovalarm and the signal SIGALRM will not be delivered.
61067fe639SAndrey A. Chernov.Pp
62067fe639SAndrey A. ChernovDue to
63067fe639SAndrey A. Chernov.Xr setitimer 2
64067fe639SAndrey A. Chernovrestriction the maximum number of
655c564baeSRuslan Ermilov.Fa seconds
66067fe639SAndrey A. Chernovallowed is 100000000.
67067fe639SAndrey A. Chernov.Sh RETURN VALUES
68b4176c89SMike PritchardThe return value of
69b4176c89SMike Pritchard.Fn alarm
70b4176c89SMike Pritchardis the amount of time left on the timer from a previous call to
71b4176c89SMike Pritchard.Fn alarm .
72b4176c89SMike PritchardIf no alarm is currently set, the return value is 0.
7358f0484fSRodney W. Grimes.Sh SEE ALSO
7458f0484fSRodney W. Grimes.Xr setitimer 2 ,
7575141cc9SWolfram Schneider.Xr sigaction 2 ,
76c84cab56SJilles Tjoelker.Xr sigsuspend 2 ,
7758f0484fSRodney W. Grimes.Xr signal 3 ,
7858f0484fSRodney W. Grimes.Xr sleep 3 ,
7958f0484fSRodney W. Grimes.Xr ualarm 3 ,
8058f0484fSRodney W. Grimes.Xr usleep 3
8153cd6483SMike Pritchard.\" .Sh STANDARDS
8253cd6483SMike Pritchard.\" The
8353cd6483SMike Pritchard.\" .Fn alarm
8453cd6483SMike Pritchard.\" function conforms to
8553cd6483SMike Pritchard.\" .St -p1003.1-90 .
8658f0484fSRodney W. Grimes.Sh HISTORY
8758f0484fSRodney W. GrimesAn
8858f0484fSRodney W. Grimes.Fn alarm
89*4b7f35dbSGordon Berglingsystem call appeared in the Programmer's Workbench (PWB/UNIX)
90*4b7f35dbSGordon Berglingand was ported to
9158f0484fSRodney W. Grimes.At v7 .
92*4b7f35dbSGordon BerglingFor
93*4b7f35dbSGordon Bergling.Bx 4.1c ,
94*4b7f35dbSGordon Berglingit was reimplemented as a wrapper around the
95*4b7f35dbSGordon Bergling.Xr setitimer 2
96*4b7f35dbSGordon Berglingsystem call.
97