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.

> 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?

Reply via email to