*
* Author: S. Piccardi Jan. 2003
*
- * $Id: ReadMonitor.c,v 1.2 2003/01/12 00:24:28 piccardi Exp $
+ * $Id: ReadMonitor.c,v 1.5 2003/05/02 09:55:14 piccardi Exp $
*
*****************************************************************************/
#include <sys/types.h>
* ***********************************************************/
/* 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 */