gtpc2m0d | C/C++ Language Support User's Guide |
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);
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