Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 X-Mailer: Mozilla 4.7 [en] (X11; I; SunOS 5.8 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: Marcello 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 > #include 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/