xref: /titanic_52/usr/src/man/man2/alarm.2 (revision fca4268092e9961ebb9b5e0098dcebc545023586)
te
Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
Copyright 1989 AT&T.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
ALARM 2 "Jun 6, 2007"
NAME
alarm - schedule an alarm signal
SYNOPSIS

#include <unistd.h>

unsigned int alarm(unsigned int seconds);
DESCRIPTION

The alarm() function causes the system to generate a SIGALRM signal for the process after the number of real-time seconds specified by seconds have elapsed (see signal.h(3HEAD)). Processor scheduling delays may prevent the process from handling the signal as soon as it is generated.

If seconds is 0, a pending alarm request, if any, is cancelled. If seconds is greater than LONG_MAX/hz, seconds is rounded down to LONG_MAX/hz. The value of hz is normally 100.

Alarm requests are not stacked; only one SIGALRM generation can be scheduled in this manner; if the SIGALRM signal has not yet been generated, the call will result in rescheduling the time at which the SIGALRM signal will be generated.

The fork(2) function clears pending alarms in the child process. A new process image created by one of the exec(2) functions inherits the time left to an alarm signal in the old process's image.

RETURN VALUES

If there is a previous alarm request with time remaining, alarm() returns a non-zero value that is the number of seconds until the previous request would have generated a SIGALRM signal. Otherwise, alarm() returns 0.

ERRORS

The alarm() function is always successful; no return value is reserved to indicate an error.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Standard
MT-Level Async-Signal-Safe
SEE ALSO

exec(2), fork(2), signal.h(3HEAD), attributes(5), standards(5)