delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/28/18:15:09

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3C056FB7.C859BA64@ece.gatech.edu>
Date: Wed, 28 Nov 2001 18:13:59 -0500
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
X-Mailer: Mozilla 4.7 [en] (X11; I; SunOS 5.8 sun4u)
X-Accept-Language: en
MIME-Version: 1.0
To: Marcello <piteko AT yahoo DOT com>
CC: cygwin AT cygwin DOT com
Subject: Re: semget and permission denied
References: <20011128170550 DOT 78398 DOT qmail AT web11603 DOT mail DOT yahoo DOT com>
X-Virus-Scanned: by amavisd-milter (http://amavis.org/)

Marcello wrote:
> 
> Hi,
> I am working with semaphores. When I try to get a semaphore, I use
> semget, but it returns me a value <0. The strerror is: Permission
> denied
> I tried in different ways, but it still doesn't work...
> Can you help me?
> 
> --------------------------------------------------------------------
> #include <sys/types.h>
> #include <sys/ipc.h>

Since cygipc-1.10, you don't need to explicitly include sys/ipc.h (but
it doesn't hurt).  According to SUSv2, sem.h (and msg.h and shm.h) are
required to #include ipc.h for you -- but I don't know if Linux obeys
that.  cygipc-1.10 and 1.11 DO obey that.

> 
>         union semun {
>                 int val;
>                 struct semid_ds *buf;
>                 ushort * array;
>         } argument;

Geez, Marcello -- AGAIN with the *wrong* definition here.  Of course,
you may be experiencing the problem I was AFRAID would happen when I
changed the signature of semctl() -- I am still not sure that it is
legal to pass a union as a vararg.  I haven't tried to run this thru gdb
yet -- I was kinda hoping that fixing everybody's problems with cygipc
was not solely my responsibility

It's possible that what you SHOULD do, is revert to cygipc-1.10, and
remove all definitions of 'union semun' from your own code; just accept
the definition that cygipc-1.10's sem.h provides.

Now, that will ALSO mean you have to use the 4-argument form of semctl()
in all cases (the 4th arg is NOT optional in cygipc-1.10, nor in
linux).  However, changing all of your semctl() calls to the 4-arg form
will NOT make your program less portable.  Other IPC implementations
accept that 4-arg form, but if they don't need the 4th arg then they
just ignore it.

--Chuck

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019