Re: signal handling issues

Liste des GroupesRevenir à cu programmer 
Sujet : Re: signal handling issues
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.programmer
Date : 30. Jan 2025, 20:49:58
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250130114503.356@kylheku.com>
References : 1 2
User-Agent : slrn/pre1.0.4-9 (Linux)
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.)

As those are library functions
which invoke kernel system calls, unless they mask signals, they can
be interrupted while they own exclusive access to the stream.
>
Subsequent accesses from a signal handler to that stream
will block indefinitely.

But those functions were never dubbed async safe; the first requirement
quoted by Rainer from Issue 6 already makes it undefined to call putc
from a signal handler interrupting putc.

That covers all situations in which the interrupt would observe
stdio to be in any kind of bad state, including holding a mutex.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
30 Jan 25 * signal handling issues14Rainer Weikusat
30 Jan 25 +- Re: signal handling issues1Rainer Weikusat
30 Jan 25 +* Re: signal handling issues4Kaz Kylheku
30 Jan 25 i`* Re: signal handling issues3Dan Cross
31 Jan 25 i `* Re: signal handling issues2Rainer Weikusat
31 Jan 25 i  `- Re: signal handling issues1Dan Cross
30 Jan 25 +* Re: signal handling issues5Kaz Kylheku
31 Jan 25 i`* Re: signal handling issues4Muttley
1 Feb 25 i `* Re: signal handling issues3Lawrence D'Oliveiro
2 Feb 25 i  `* Re: signal handling issues2Muttley
4 Feb 25 i   `- Re: signal handling issues1Rainer Weikusat
3 Feb 25 `* Re: signal handling issues3Geoff Clare
6 Feb 25  `* Re: signal handling issues2Geoff Clare
6 Feb 25   `- Re: signal handling issues1Rainer Weikusat

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal