Commit | Line | Data |
---|---|---|
b8f253e8 KM |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
d0286ffa KB |
3 | * All rights reserved. |
4 | * | |
269a7923 | 5 | * %sccs.include.redist.c% |
b8f253e8 KM |
6 | */ |
7 | ||
2ce81398 | 8 | #if defined(LIBC_SCCS) && !defined(lint) |
269a7923 | 9 | static char sccsid[] = "@(#)alarm.c 5.4 (Berkeley) %G%"; |
d0286ffa | 10 | #endif /* LIBC_SCCS and not lint */ |
30e720bf SL |
11 | |
12 | /* | |
13 | * Backwards compatible alarm. | |
14 | */ | |
15 | #include <sys/time.h> | |
16 | ||
17 | alarm(secs) | |
18 | int secs; | |
19 | { | |
20 | struct itimerval it, oitv; | |
21 | register struct itimerval *itp = ⁢ | |
22 | ||
23 | timerclear(&itp->it_interval); | |
24 | itp->it_value.tv_sec = secs; | |
25 | itp->it_value.tv_usec = 0; | |
26 | if (setitimer(ITIMER_REAL, itp, &oitv) < 0) | |
27 | return (-1); | |
27130bed RC |
28 | if (oitv.it_value.tv_usec) |
29 | oitv.it_value.tv_sec++; | |
30e720bf SL |
30 | return (oitv.it_value.tv_sec); |
31 | } |