Learn R Programming

fame (version 1.03)

alarmc: Interface to alarm() system call

Description

This is a simple wrapper around the POSIX alarm() system call. Unfortunately, it is not available on Windows.

Usage

alarmc(seconds = 0)

Arguments

seconds
integer number of seconds to wait before sending SIGALRM to the Rprocess, or 0 (zero) to cancel any existing timer.

Details

alarmc(seconds) sets a timer running for seconds seconds and returns immediately. The default value 0 unsets the timer, if there is one.

When the time is up, the SIGALRM signal is sent to the Rprocess. Since Rdoes not define a handler for this signal, the default handler is invoked, which terminates the Rprocess.

References

See the man page for alarm

See Also

Sys.sleep

Examples

Run this code
## wait up to 10 minutes for a socket connection or die
alarmc(600) 
conn <- socketConnection(port = 40001, server = T, blocking = T)
alarmc(0)  ## turn off the timer
incomingText <- readLines(conn)
close(conn)

Run the code above in your browser using DataLab