122079Smckusick /* 222079Smckusick * Copyright (c) 1983 Regents of the University of California. 335304Sbostic * All rights reserved. 435304Sbostic * 5*42620Sbostic * %sccs.include.redist.c% 622079Smckusick */ 712973Ssam 826541Sdonn #if defined(LIBC_SCCS) && !defined(lint) 9*42620Sbostic static char sccsid[] = "@(#)alarm.c 5.4 (Berkeley) 06/01/90"; 1035304Sbostic #endif /* LIBC_SCCS and not lint */ 1122079Smckusick 1212973Ssam /* 1312973Ssam * Backwards compatible alarm. 1412973Ssam */ 1512973Ssam #include <sys/time.h> 1612973Ssam 1712973Ssam alarm(secs) 1812973Ssam int secs; 1912973Ssam { 2012973Ssam struct itimerval it, oitv; 2112973Ssam register struct itimerval *itp = ⁢ 2212973Ssam 2312973Ssam timerclear(&itp->it_interval); 2412973Ssam itp->it_value.tv_sec = secs; 2512973Ssam itp->it_value.tv_usec = 0; 2612973Ssam if (setitimer(ITIMER_REAL, itp, &oitv) < 0) 2712973Ssam return (-1); 2816215Sralph if (oitv.it_value.tv_usec) 2916215Sralph oitv.it_value.tv_sec++; 3012973Ssam return (oitv.it_value.tv_sec); 3112973Ssam } 32