On Mon, Feb 24 2020 10:24:53 +0100, Martin Pieuchot wrote:
> On 23/02/20(Sun) 14:48, Lauri Tirkkonen wrote:
> > I was working on a make jobserver implementation that uses POSIX
> > semaphores as job tokens instead of a complicated socket-based approach.
> > Initially I used named semaphores, which work fine, except if child
> > processes with less privileges need to also open the named semaphore
> > (eg. 'make build' as root executing 'su build -c make'). For that reason
> > I wanted to use an unnamed semaphore (sem_init()) which is stored in shm
> > -- that way I could leave the shm fd open and pass it to children.
> > 
> > But unfortunately, sem_t is currently just a pointer to the opaque
> > struct __sem, and sem_int() always calloc()s the storage for the struct.
> 
> That's by design.

Ok - could you elaborate what the design is?

> > This means the application cannot control where unnamed semaphores are
> > stored, so I can't put it in shm.
> 
> Are you trying to use semaphore shared between process?  Did you called
> sem_init() with pshared=1?  Have you seen that the current implementation
> doesn't support them?

Yes, that's what I'm trying to do. Yes, I've seen the current
implementation -- that's why I started this thread, in an attempt to
make them supported. :)

See the followup patch -- sharing the semaphore between processes does
work with it.

-- 
Lauri Tirkkonen | lotheac @ IRCnet

Reply via email to