ANSI C; sprintf now returns an int.
[unix-history] / usr / src / lib / libc / gen / alarm.c
CommitLineData
b8f253e8
KM
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
2ce81398
DS
7#if defined(LIBC_SCCS) && !defined(lint)
8static char sccsid[] = "@(#)alarm.c 5.2 (Berkeley) %G%";
9#endif LIBC_SCCS and not lint
30e720bf
SL
10
11/*
12 * Backwards compatible alarm.
13 */
14#include <sys/time.h>
15
16alarm(secs)
17 int secs;
18{
19 struct itimerval it, oitv;
20 register struct itimerval *itp = &it;
21
22 timerclear(&itp->it_interval);
23 itp->it_value.tv_sec = secs;
24 itp->it_value.tv_usec = 0;
25 if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
26 return (-1);
27130bed
RC
27 if (oitv.it_value.tv_usec)
28 oitv.it_value.tv_sec++;
30e720bf
SL
29 return (oitv.it_value.tv_sec);
30}