Mail Archives: cygwin/2001/11/28/18:15:09
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 -