BSD 4_3_Tahoe release
[unix-history] / usr / src / etc / update.c
index 8688984..3b4d449 100644 (file)
@@ -1,10 +1,23 @@
-static char *sccsid = "@(#)update.c    4.2 (Berkeley) 10/16/80";
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)update.c   4.3 (Berkeley) 3/28/87";
+#endif
+
 /*
  * Update the file system every 30 seconds.
  * For cache benefit, open certain system directories.
  */
 
 /*
  * Update the file system every 30 seconds.
  * For cache benefit, open certain system directories.
  */
 
-#include <signal.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <sys/signal.h>
+#include <syslog.h>
+#include <stdio.h>
 
 char *fillst[] = {
        "/bin",
 
 char *fillst[] = {
        "/bin",
@@ -18,23 +31,26 @@ char *fillst[] = {
 
 main()
 {
 
 main()
 {
-       char **f;
+       struct itimerval        value;
+       register char   **f;
+       extern int      sync();
 
 
-       if(fork())
+       if (fork())
                exit(0);
                exit(0);
-       close(0);
-       close(1);
-       close(2);
-       for(f = fillst; *f; f++)
-               open(*f, 0);
-       dosync();
-       for(;;)
+       (void)close(0);
+       (void)close(1);
+       (void)close(2);
+       for (f = fillst; *f; f++)
+               (void)open(*f, O_RDONLY, 0);
+       (void)signal(SIGALRM, sync);
+       value.it_interval.tv_sec = 30;
+       value.it_interval.tv_usec = 0;
+       value.it_value = value.it_interval;
+       if (setitimer(ITIMER_REAL, &value, (struct itimerval *)NULL)) {
+               perror("update: setitimer");
+               exit(1);
+       }
+       for (;;)
                pause();
                pause();
-}
-
-dosync()
-{
-       sync();
-       signal(SIGALRM, dosync);
-       alarm(30);
+       /*NOTREACHED*/
 }
 }