xref: /original-bsd/usr.bin/f77/libU77/alarm_.c (revision a141c157)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)alarm_.c	5.1	06/07/85
7  */
8 
9 /*
10  * set an alarm time, arrange for user specified action, and return.
11  *
12  * calling sequence:
13  *	integer	flag
14  *	external alfunc
15  *	lastiv = alarm (intval, alfunc)
16  * where:
17  *	intval	= the alarm interval in seconds; 0 turns off the alarm.
18  *	alfunc	= the function to be called after the alarm interval,
19  *
20  *	The returned value will be the time remaining on the last alarm.
21  */
22 
23 #include <signal.h>
24 
25 long alarm_(sec, proc)
26 long	*sec;
27 int	(* proc)();
28 {
29 	register long	lt;
30 
31 	lt = alarm(1000);	/* time to maneuver */
32 
33 	if (*sec)
34 		signal(SIGALRM, proc);
35 
36 	alarm(*sec);
37 	return(lt);
38 }
39