[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: data structures for use in signal handlers

From: Eric Wong
Subject: Re: data structures for use in signal handlers
Date: Wed, 10 Feb 2021 01:21:18 +0000

Bruno Haible <bruno@clisp.org> wrote:
> Hi Eric,
> Eric Wong wrote:
> > I would've recommended just using a pipe, socket or eventfd;
> How would setting up a pipe or eventfd help with a communication
> problem between threads in the same process? I thought these were
> for communication between processes.

The "self-pipe trick" is a common idiom in Unix for signal
handling; especially when pselect/ppoll aren't available.
I seem to recall learning of it reading something by djb.

It's perfectly valid to use pipes in single-threaded or
multi-threaded, or multi-process situations.  POSIX gives
well-defined semantics w.r.t. atomicity.

I know the (C)Ruby VM uses it internally (or eventfd on Linux);
I think CPython's GVL does, too.

My gnulib-using cmogstored uses a self-pipe when epoll_pwait
isn't available (Though it could probably use EVFILT_SIGNAL on

reply via email to

[Prev in Thread] Current Thread [Next in Thread]