Re: sem_open really strange behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks a lot Andrew,

I read that paragraph thousand of times. However it is not an answer why it works if a line is commented or not. I cannot figure an acceptable explanation, that's why I thought it will be a gcc question.

On 22-06-2010 9:23, Andrew Bell wrote:
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,




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux