gtpc2m0dC/C++ Language Support User's Guide

alarm-Schedule an Alarm

This function causes the TPF system to send the calling process a SIGALRM signal after a specified amount of time has elapsed.

Format

#include <unistd.h>
unsigned int alarm(unsigned int time_value);

time_value
Specifies, in seconds, the number of time units until SIGALRM is generated. The maximum time value is 65 535. A higher value can be specified, but a value of 65 535 will actually be used. A value of zero causes an outstanding alarm request to be canceled and the SIGALRM signal will not be sent.

Normal Return

The alarm function is always successful.

If there is a previous alarm request with time remaining, the alarm function returns the number of seconds until the previous request would have generated a SIGALRM signal. If the remaining time includes a fraction of a second, it is rounded up to the next second in the return value. Otherwise, the alarm function returns zero.

Error Return

Not applicable.

Programming Considerations

Alarm requests are not stacked. If the SIGALRM signal has not yet been generated, the call results in rescheduling the time when SIGALRM will be generated.

Examples

The following example shows how to set an alarm.

#include <unistd.h>
unsigned int my_alarm = 3;  /* three seconds */
 

·
·
·
/* Set alarm before entering select statement*/ rc = alarm(my_alarm);
·
·
·

Related Information