xref: /original-bsd/usr.sbin/update/update.c (revision 35d77a20)
1 /*-
2  * Copyright (c) 1987, 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 char copyright[] =
10 "@(#) Copyright (c) 1987, 1990 The Regents of the University of California.\n\
11  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)update.c	5.1 (Berkeley) 06/06/91";
16 #endif /* not lint */
17 
18 #include <sys/time.h>
19 #include <signal.h>
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <unistd.h>
23 
24 main()
25 {
26 	struct itimerval value;
27 	void mysync();
28 
29 	daemon(0, 0);
30 
31 	(void)signal(SIGALRM, mysync);
32 
33 	value.it_interval.tv_sec = 30;
34 	value.it_interval.tv_usec = 0;
35 	value.it_value = value.it_interval;
36 	if (setitimer(ITIMER_REAL, &value, NULL)) {
37 		perror("update: setitimer");
38 		exit(1);
39 	}
40 	for (;;)
41 		sigpause(sigblock(0L));
42 	/* NOTREACHED */
43 }
44 
45 void
46 mysync()
47 {
48 	(void)sync();
49 }
50