xref: /original-bsd/usr.sbin/update/update.c (revision 5f5c18da)
1 /*
2  * Copyright (c) 1987 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 
7 #ifndef lint
8 static char sccsid[] = "@(#)update.c	4.4 (Berkeley) 05/11/89";
9 #endif
10 
11 /*
12  * Update the file system every 30 seconds.
13  * For cache benefit, open certain system directories.
14  */
15 
16 #include <sys/time.h>
17 #include <sys/file.h>
18 #include <sys/signal.h>
19 #include <syslog.h>
20 #include <stdio.h>
21 #include "pathnames.h"
22 
23 main()
24 {
25 	struct itimerval	value;
26 	register char	**f;
27 	extern int	sync();
28 
29 	if (fork())
30 		exit(0);
31 	(void)close(0);
32 	(void)close(1);
33 	(void)close(2);
34 	for (f = fillst; *f; f++)
35 		(void)open(*f, O_RDONLY, 0);
36 	(void)signal(SIGALRM, sync);
37 	value.it_interval.tv_sec = 30;
38 	value.it_interval.tv_usec = 0;
39 	value.it_value = value.it_interval;
40 	if (setitimer(ITIMER_REAL, &value, (struct itimerval *)NULL)) {
41 		perror("update: setitimer");
42 		exit(1);
43 	}
44 	for (;;)
45 		pause();
46 	/*NOTREACHED*/
47 }
48