Sujet : Re: signal handling issues
De : Muttley (at) *nospam* DastardlyHQ.org
Groupes : comp.unix.programmerDate : 31. Jan 2025, 10:15:39
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vni4br$3ehhv$1@dont-email.me>
References : 1 2 3
On Thu, 30 Jan 2025 19:49:58 -0000 (UTC)
Kaz Kylheku <
643-408-1753@kylheku.com> wibbled:
On 2025-01-30, Scott Lurndal <scott@slp53.sl.home> wrote:
Rainer Weikusat <rweikusat@talktalk.net> writes:
If the process is multi-threaded, or if the process is
single-threaded and a signal handler is executed other than as
the result of:
>
While Geoff may chime in with the definitive answer, once
multithreading was introduced, the stdio library functions
were required to synchronize access to the underlying
FILE buffers between threads.
>
But the requirement applies to a single-threaded program in
which an asynchronous signal occurs.
>
The multi-threaded case seems to say that if the program is MT,
then if a signal occurs even as a result of the program
calling raise, etc, it is effectivecly an async signal
(since it happens as the result of a thread executing
asynchronously with regard to whatever thread catches the signal
via a handler.)
All this confusion and complexity is why I always recommend that in a
multithreaded program if you must use signals then all signals should be
blocked with a single thread dedicated to sitting in sigwait() and handling
whatever comes along.