[Xcb] [libpthread-stubs] fix semaphore signal safety

Samuel Thibault samuel.thibault at ens-lyon.org
Sat Sep 26 09:09:10 PDT 2009

Jamey Sharp, le Sat 26 Sep 2009 08:59:14 -0700, a écrit :
> On Sat, Sep 26, 2009 at 6:52 AM, Samuel Thibault
> <samuel.thibault at ens-lyon.org> wrote:
> > I've just realized that sem_post() is allowed to be called from a signal
> > handler, so the semaphore implementation has to be signal-safe, here is
> > a patch.
> Huh, I missed something when the original patches went by. Why do
> these stubs need to do anything? pthread_mutex_lock, for instance, is
> a complete no-op.

Because they are not supposed to do anything without threads.

> Is this because "The mutex functions are not async-signal safe"
> (pthread_mutex_lock(3)) so can't possibly be used in a single-threaded
> program, but the semaphore functions apparently can?


> Still, it seems to me that if somebody expects the semaphore functions
> to actually do something, they should link with pthread.

As the name suggests, semaphores are not so much related with pthreads,
the sem_* functions were even probably introduced before pthreads.
It happens that on Linux and a few others OSes it's implemented in
libpthread, but there is no real reason for that, particularly since
they can even be inter-processes and still not have anything to do with


More information about the Xcb mailing list