On Tue, Jun 22, 2010 at 8:16 AM, Sergio Sobarzo <ssobarzo@xxxxxxxxx> wrote: > Hi, > > I'm writing an application using semaphores. Here is a simple code > recreating the problem: > > *********************************************** > #include <sys/types.h> > #include <stdio.h> > #include <semaphore.h> > #include <sys/types.h> > #include <sys/stat.h> > #include <fcntl.h> > #include <stdlib.h> > > int main() > { > int ok; > //key_t t; > char *shm,*s; > sem_t *mutex; > > mutex = sem_open("/vik",O_CREAT|O_EXCL); > if(mutex == SEM_FAILED) > { > perror("unable to create semaphore"); > sem_unlink("vik"); > exit(-1); > } > > sem_close(mutex); > sem_unlink("vik"); > exit(0); > } > ************************************************ The man page for sem_open says that if you include O_CREAT as a flag you must also provide the mode and value arguments. Have you tried that? P.S. - This isn't a gcc issue - you should probably post this to a general UNIX programming list. Best, -- Andrew Bell andrew.bell.ia@xxxxxxxxx