Corretti i commenti ai listati in una forma piu' leggibile (spero).
[gapil.git] / listati / DirMonitor.c
index edd5bb9eae458c0216207eb5cd794070dcaace30..65173c86ddef116fcf188c8d4d578efb7949d7d0 100644 (file)
@@ -17,33 +17,33 @@ int main(int argc, char *argv[])
 {
     int i, pause = 10;
     ...
-    if ((argc - optind) != 1) {          /* There must be remaing parameters */
+    if ((argc - optind) != 1) {   /* There must be remaing parameters */
         printf("Wrong number of arguments %d\n", argc - optind);
         usage();
     }
-    if (chdir(argv[1])) {                      /* chdir to be sure dir exist */
+    if (chdir(argv[1])) {         /* chdir to be sure dir exist */
         perror("Cannot find directory to monitor");
     }
-    Signal(SIGTERM, HandSIGTERM);            /* set handlers for termination */
+    Signal(SIGTERM, HandSIGTERM); /* set handlers for termination */
     Signal(SIGINT, HandSIGTERM);
     Signal(SIGQUIT, HandSIGTERM);
-    key = ftok("~/gapil/sources/DirMonitor.c", 1);           /* define a key */
-    shmptr = ShmCreate(key, 4096, 0666, 0);   /* get a shared memory segment */
+    key = ftok("~/gapil/sources/DirMonitor.c", 1); /* define a key */
+    shmptr = ShmCreate(key, 4096, 0666, 0); /* get a shared memory segment */
     if (!shmptr) {
         perror("Cannot create shared memory");
         exit(1);
     }
-    if ((mutex = MutexCreate(key)) == -1) {                   /* get a Mutex */
+    if ((mutex = MutexCreate(key)) == -1) {        /* get a Mutex */
         perror("Cannot create mutex");
         exit(1);
     }
     /* main loop, monitor directory properties each 10 sec */
-    daemon(1, 0);              /* demonize process, staying in monitored dir */
+    daemon(1, 0);           /* demonize process, staying in monitored dir */
     while (1) {
-        MutexLock(mutex);                              /* lock shared memory */
-        memset(shmptr, 0, sizeof(struct DirProp));    /* erase previous data */
-        DirScan(argv[1], ComputeValues);                     /* execute scan */
-        MutexUnlock(mutex);                          /* unlock shared memory */
-        sleep(pause);                              /* sleep until next watch */
+        MutexLock(mutex);   /* lock shared memory */
+        memset(shmptr, 0, sizeof(struct DirProp)); /* erase previous data */
+        DirScan(argv[1], ComputeValues);           /* execute scan */
+        MutexUnlock(mutex); /* unlock shared memory */
+        sleep(pause);       /* sleep until next watch */
     }
 }