Merge branch 'master' of ssh://gapil.gnulinux.it/srv/git/gapil
[gapil.git] / sources / ReadMonitor.c
index 80a77c7f71815cf2828f9507d1c35363536de0b5..6695f2a04990c9ddc06d04300b9b4d195aff07dc 100644 (file)
  *
  * Author: S. Piccardi Jan. 2003
  *
- * $Id: ReadMonitor.c,v 1.1 2003/01/10 09:28:49 piccardi Exp $
- *
  *****************************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>        /* directory */
-#include <stdlib.h>        /* C standard library */
-#include <unistd.h>
+#include <sys/types.h>   /* primitive system data types */
+#include <sys/stat.h>    /* file characteristics constants and functions */
+#include <dirent.h>      /* directory operation constants and functions */
+#include <stdlib.h>      /* C standard library */
+#include <unistd.h>      /* unix standard library */
 
 #include "Gapil.h"
 #include "macros.h"
@@ -90,19 +88,13 @@ int main(int argc, char *argv[])
      * 
      * ***********************************************************/
     /* create needed IPC objects */
-    key = ftok("./DirMonitor.c", 1);                         /* define a key */
-    shmid = shmget(key, 4096, 0);                  /* get a shared memory ID */
-    if (shmid < 0) {
+    key = ftok("~/gapil/sources/DirMonitor.c", 1);           /* define a key */
+    if (!(shmptr = ShmFind(key, 4096))) {     /* get a shared memory segment */
        perror("Cannot find shared memory");
        exit(1);
     }
-    if ( (shmptr = shmat(shmid, NULL, 0)) == NULL ) {   /* attach to process */
-       perror("Cannot attach segment");
-       exit(1);
-    }
     if ((mutex = MutexFind(key)) == -1) {                   /* get the Mutex */
        perror("Cannot find mutex");
-       exit(1);
     }
     /* main loop */
     MutexLock(mutex);                                  /* lock shared memory */