Try this to fix your lab5.c program:


1. Name your semaphores with a unique name.

       sem1 = sem_open("/myname1", O_CREAT, 0644, 0);
       sem2 = sem_open("/myname2", O_CREAT, 0644, 1);

   note: do not use myname1 and myname2.


2. At end of parent, call sem_close() on both semaphores.
   Then call sem_unlink() on each semaphore name.

       sem_close(sem1);
       sem_close(sem2);
       sem_unlink("/myname1");
       sem_unlink("/myname2");

3. Run cleanup.sh to clean your shared memory.