1: /* 2: char id_alarm[] = "@(#)alarm_.c 1.1"; 3: * 4: * set an alarm time, arrange for user specified action, and return. 5: * 6: * calling sequence: 7: * integer flag 8: * external alfunc 9: * lastiv = alarm (intval, alfunc) 10: * where: 11: * intval = the alarm interval in seconds; 0 turns off the alarm. 12: * alfunc = the function to be called after the alarm interval, 13: * 14: * The returned value will be the time remaining on the last alarm. 15: */ 16: 17: #include "../libI77/fiodefs.h" 18: #include <signal.h> 19: 20: ftnint alarm_(sec, proc) 21: ftnint *sec; 22: int (* proc)(); 23: { 24: register ftnint lt; 25: 26: lt = (ftnint) alarm(1000); /* time to maneuver */ 27: 28: if (*sec) 29: signal(SIGALRM, proc); 30: 31: alarm((unsigned) *sec); 32: return(lt); 33: }