alarm()

NAME

alarm() - set signal timer alarm

SYNOPSIS

#include <unistd.h>

unsigned int alarm (unsigned int seconds)

DESCRIPTION

The alarm(2) function sets a countdown timer that waits seconds before asserting the terminating signal SIGALRM; alarm(2) returns immediately after setting the timer.

If there is a pending alarm(2) request, the call to alarm(2) replaces the prior call. In this case, the alarm(2) function returns the number of seconds left on the prior call's timer.

To cancel an alarm without setting a new one, pass 0 as the seconds argument.

The maximum number of seconds allowed is the maximum value of an unsigned int.

RETURN VALUE

If there is no other alarm(2) request pending, alarm(2) returns 0 after setting the timer.

If there is another alarm(2) request pending, alarm(2) returns the number of seconds remaining until the previous request would have generated a SIGALRM signal.

SEE ALSO

sigaction(2)

signal(2)

sleep(3)