1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)alarm_.c 5.2 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 /* 13 * set an alarm time, arrange for user specified action, and return. 14 * 15 * calling sequence: 16 * integer flag 17 * external alfunc 18 * lastiv = alarm (intval, alfunc) 19 * where: 20 * intval = the alarm interval in seconds; 0 turns off the alarm. 21 * alfunc = the function to be called after the alarm interval, 22 * 23 * The returned value will be the time remaining on the last alarm. 24 */ 25 26 #include <signal.h> 27 28 long alarm_(sec, proc) 29 long *sec; 30 int (* proc)(); 31 { 32 register long lt; 33 34 lt = alarm(1000); /* time to maneuver */ 35 36 if (*sec) 37 signal(SIGALRM, proc); 38 39 alarm(*sec); 40 return(lt); 41 } 42