Re: signal handling issues

Liste des GroupesRevenir à cu programmer 
Sujet : Re: signal handling issues
De : rweikusat (at) *nospam* talktalk.net (Rainer Weikusat)
Groupes : comp.unix.programmer
Date : 30. Jan 2025, 20:11:14
Autres entêtes
Message-ID : <87zfj8yv59.fsf@doppelsaurus.mobileactivedefense.com>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
scott@slp53.sl.home (Scott Lurndal) writes:
Rainer Weikusat <rweikusat@talktalk.net> writes:
Up to and including The Open Group Base Specifications Issue 6, the
following program was a correct way of using signal handlers:
>
----

[example program removed]

----
>
As the only requirement for functions not listed as async-signal-safe
was
>
In the presence of signals, all functions defined by this volume
of IEEE Std 1003.1-2001 shall behave as defined when called from
or interrupted by a signal-catching function, with a single
exception: when a signal interrupts an unsafe function and the
signal-catching function calls an unsafe function, the behavior
is undefined.
>
Since version 7, its behaviour is undefined because the following
requirement was added:
>
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:

[signal being synchronously raised

... otherwise, behaviour always undefined if handler calls any unsafe
function regardless of the older requirement quoted above]

[...]

once multithreading was introduced, the stdio library functions were
required to synchronize access to the underlying FILE buffers between
threads.  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.

These functions were never async-signal-safe and I don't quite
understand why this locking would necessarily conflict with the
requirement that unsafe functions shall behave as documented when called
from a signal handler or interrupted by a signal unless the signal
handler interrupted an unsafe function and also called an unsafe
function.

For stdio, this basically just means that a stream used by some stdio
routine must be unlocked by the time it returns to its caller.

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