man-pages/man3/ualarm.3

112 lines
3.2 KiB
Groff

.\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
.\"
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, write to the Free
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.TH UALARM 3 2003-07-24 "" "Linux Programmer's Manual"
.SH NAME
ualarm \- schedule signal after given number of microseconds
.SH SYNOPSIS
.nf
/* BSD version */
.B "#include <unistd.h>"
.sp
.BI "unsigned int"
.br
.BI "ualarm(unsigned int " usecs ", unsigned int " interval );
.sp
/* SUSv2 version */
.B "#define _XOPEN_SOURCE 500"
.br
.B "#include <unistd.h>"
.sp
.BI "useconds_t ualarm(useconds_t " usecs ", useconds_t " interval );
.fi
.SH DESCRIPTION
The \fBualarm()\fP function causes the signal SIGALRM to be sent
to the invoking process after (not less than)
.I usecs
microseconds.
The delay may be lengthened slightly by any system activity
or by the time spent processing the call or by the
granularity of system timers.
.LP
Unless caught or ignored, this signal will terminate the process.
.LP
If the
.I interval
argument is nonzero, further SIGALRM signals will be sent every
.I interval
microseconds after the first.
.SH "RETURN VALUE"
This function returns the number of microseconds remaining from
the previous call, or 0 when no alarm is pending.
.SH ERRORS
.TP
EINTR
Interrupted by a signal.
.TP
EINVAL
\fIusecs\fP or \fIinterval\fP is not smaller than 1000000.
(On systems where that is considered an error.)
.SH "CONFORMING TO"
BSD 4.3, POSIX 1003.1-2003.
BSD 4.3, SUSv2 and POSIX do not define any errors.
.SH NOTES
The type
.B useconds_t
is an unsigned integer type capable of holding integers
in the range [0,1000000].
This type is defined by
.I <sys/types.h>
included by
.I <unistd.h>
but glibc defines it only when _XOPEN_SOURCE has a value not less than 500,
or both _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED are defined.
.\" useconds_t also gives problems on HPUX 10.
Programs will be more portable if they never mention this type explicitly.
.LP
The interaction of this function with
other timer functions such as
.IR alarm (),
.IR sleep (),
.IR nanosleep (),
.IR setitimer (),
.IR timer_create (),
.IR timer_delete (),
.IR timer_getoverrun (),
.IR timer_gettime (),
.IR timer_settime (),
.IR usleep ()
is unspecified.
.LP
This function is obsolete. Use
.BR nanosleep (2)
or
.BR setitimer (2)
instead.
.SH "SEE ALSO"
.BR alarm (2),
.BR getitimer (2),
.BR nanosleep (2),
.BR select (2),
.BR setitimer (2),
.BR usleep (3)