alarm.c (58f0484fa251c266ede97b591b499fe3dd4f578e) | alarm.c (22626efa0f96cbca4edae882e46cb56b1879706b) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ |
37#include <sys/cdefs.h> 38__FBSDID("$FreeBSD$"); |
|
37 38/* 39 * Backwards compatible alarm. 40 */ 41#include <sys/time.h> 42#include <unistd.h> 43 44unsigned int 45alarm(secs) 46 unsigned int secs; 47{ 48 struct itimerval it, oitv; | 39 40/* 41 * Backwards compatible alarm. 42 */ 43#include <sys/time.h> 44#include <unistd.h> 45 46unsigned int 47alarm(secs) 48 unsigned int secs; 49{ 50 struct itimerval it, oitv; |
49 register struct itimerval *itp = ⁢ | 51 struct itimerval *itp = ⁢ |
50 51 timerclear(&itp->it_interval); 52 itp->it_value.tv_sec = secs; 53 itp->it_value.tv_usec = 0; 54 if (setitimer(ITIMER_REAL, itp, &oitv) < 0) 55 return (-1); 56 if (oitv.it_value.tv_usec) 57 oitv.it_value.tv_sec++; 58 return (oitv.it_value.tv_sec); 59} | 52 53 timerclear(&itp->it_interval); 54 itp->it_value.tv_sec = secs; 55 itp->it_value.tv_usec = 0; 56 if (setitimer(ITIMER_REAL, itp, &oitv) < 0) 57 return (-1); 58 if (oitv.it_value.tv_usec) 59 oitv.it_value.tv_sec++; 60 return (oitv.it_value.tv_sec); 61} |