122079Smckusick /* 222079Smckusick * Copyright (c) 1983 Regents of the University of California. 3*35304Sbostic * All rights reserved. 4*35304Sbostic * 5*35304Sbostic * Redistribution and use in source and binary forms are permitted 6*35304Sbostic * provided that the above copyright notice and this paragraph are 7*35304Sbostic * duplicated in all such forms and that any documentation, 8*35304Sbostic * advertising materials, and other materials related to such 9*35304Sbostic * distribution and use acknowledge that the software was developed 10*35304Sbostic * by the University of California, Berkeley. The name of the 11*35304Sbostic * University may not be used to endorse or promote products derived 12*35304Sbostic * from this software without specific prior written permission. 13*35304Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*35304Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*35304Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1622079Smckusick */ 1712973Ssam 1826541Sdonn #if defined(LIBC_SCCS) && !defined(lint) 19*35304Sbostic static char sccsid[] = "@(#)alarm.c 5.3 (Berkeley) 08/02/88"; 20*35304Sbostic #endif /* LIBC_SCCS and not lint */ 2122079Smckusick 2212973Ssam /* 2312973Ssam * Backwards compatible alarm. 2412973Ssam */ 2512973Ssam #include <sys/time.h> 2612973Ssam 2712973Ssam alarm(secs) 2812973Ssam int secs; 2912973Ssam { 3012973Ssam struct itimerval it, oitv; 3112973Ssam register struct itimerval *itp = ⁢ 3212973Ssam 3312973Ssam timerclear(&itp->it_interval); 3412973Ssam itp->it_value.tv_sec = secs; 3512973Ssam itp->it_value.tv_usec = 0; 3612973Ssam if (setitimer(ITIMER_REAL, itp, &oitv) < 0) 3712973Ssam return (-1); 3816215Sralph if (oitv.it_value.tv_usec) 3916215Sralph oitv.it_value.tv_sec++; 4012973Ssam return (oitv.it_value.tv_sec); 4112973Ssam } 42