X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FReadMonitor.c;h=6695f2a04990c9ddc06d04300b9b4d195aff07dc;hp=9951358e5a76c5fc9f1824634d99c1935c562020;hb=26f7a8bb19c6cb198c213757a97b6ac79e40db4b;hpb=59b107d5207f19e0049bbd1032e10cba660da92e diff --git a/sources/ReadMonitor.c b/sources/ReadMonitor.c index 9951358..6695f2a 100644 --- a/sources/ReadMonitor.c +++ b/sources/ReadMonitor.c @@ -25,14 +25,12 @@ * * Author: S. Piccardi Jan. 2003 * - * $Id: ReadMonitor.c,v 1.2 2003/01/12 00:24:28 piccardi Exp $ - * *****************************************************************************/ -#include -#include -#include /* directory */ -#include /* C standard library */ -#include +#include /* primitive system data types */ +#include /* file characteristics constants and functions */ +#include /* directory operation constants and functions */ +#include /* C standard library */ +#include /* unix standard library */ #include "Gapil.h" #include "macros.h" @@ -91,18 +89,12 @@ int main(int argc, char *argv[]) * ***********************************************************/ /* create needed IPC objects */ key = ftok("~/gapil/sources/DirMonitor.c", 1); /* define a key */ - shmid = shmget(key, 4096, 0); /* get a shared memory ID */ - if (shmid < 0) { + 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 */