1*47944Sbostic /*- 2*47944Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*47944Sbostic * All rights reserved. 45353Sdlw * 5*47944Sbostic * %sccs.include.proprietary.c% 623004Skre */ 723004Skre 8*47944Sbostic #ifndef lint 9*47944Sbostic static char sccsid[] = "@(#)alarm_.c 5.2 (Berkeley) 04/12/91"; 10*47944Sbostic #endif /* not lint */ 11*47944Sbostic 1223004Skre /* 135353Sdlw * set an alarm time, arrange for user specified action, and return. 145353Sdlw * 155353Sdlw * calling sequence: 165353Sdlw * integer flag 175353Sdlw * external alfunc 185353Sdlw * lastiv = alarm (intval, alfunc) 195353Sdlw * where: 205353Sdlw * intval = the alarm interval in seconds; 0 turns off the alarm. 215353Sdlw * alfunc = the function to be called after the alarm interval, 225353Sdlw * 235353Sdlw * The returned value will be the time remaining on the last alarm. 245353Sdlw */ 255353Sdlw 265353Sdlw #include <signal.h> 275353Sdlw alarm_(sec,proc)285353Sdlwlong alarm_(sec, proc) 295353Sdlw long *sec; 305353Sdlw int (* proc)(); 315353Sdlw { 325353Sdlw register long lt; 335353Sdlw 345353Sdlw lt = alarm(1000); /* time to maneuver */ 355353Sdlw 365353Sdlw if (*sec) 375353Sdlw signal(SIGALRM, proc); 385353Sdlw 395353Sdlw alarm(*sec); 405353Sdlw return(lt); 415353Sdlw } 42