122079Smckusick /* 2*61111Sbostic * Copyright (c) 1983, 1993 3*61111Sbostic * The Regents of the University of California. All rights reserved. 435304Sbostic * 542620Sbostic * %sccs.include.redist.c% 622079Smckusick */ 712973Ssam 826541Sdonn #if defined(LIBC_SCCS) && !defined(lint) 9*61111Sbostic static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 06/04/93"; 1035304Sbostic #endif /* LIBC_SCCS and not lint */ 1122079Smckusick 1212973Ssam /* 1312973Ssam * Backwards compatible alarm. 1412973Ssam */ 1512973Ssam #include <sys/time.h> 1646597Sdonn #include <unistd.h> 1712973Ssam 1846597Sdonn unsigned int alarm(secs)1912973Ssamalarm(secs) 2046597Sdonn unsigned int secs; 2112973Ssam { 2212973Ssam struct itimerval it, oitv; 2312973Ssam register struct itimerval *itp = ⁢ 2412973Ssam 2512973Ssam timerclear(&itp->it_interval); 2612973Ssam itp->it_value.tv_sec = secs; 2712973Ssam itp->it_value.tv_usec = 0; 2812973Ssam if (setitimer(ITIMER_REAL, itp, &oitv) < 0) 2912973Ssam return (-1); 3016215Sralph if (oitv.it_value.tv_usec) 3116215Sralph oitv.it_value.tv_sec++; 3212973Ssam return (oitv.it_value.tv_sec); 3312973Ssam } 34