Using `blockUserSignals` is unnecessary and it will probably be deprecated
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 30/100
- Issue-Typ
- Refactoring
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Bereich
- operating-systems
Rechercherichtung
Start with the fork and signal-handling code in cbits/posix/fork_exec.c, including the surrounding comments and calls to blockUserSignals, unblockUserSignals, stopTimer and startTimer. Work out how the signal mask and shared pipe behave in the parent and child before choosing an approach. Done means the fork path handles signals safely without relying on the RTS functions this issue proposes removing.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The blockUserSignals / unblockUserSignals functions are exported from the RTS. These functions are (almost certainly) vestiges of an long since gone design in the (non-threaded) RTS for signal handling. The RTS probably does not need them any more any they will probably be deprecated and removed. See GHC ticket #27968
They are used however in cbits/posix/fork_exec.c before/after the fork(). The surrounding comments explain:
// Block signals with Haskell handlers. The danger here is that
// with the threaded RTS, a signal arrives in the child process,
// the RTS writes the signal information into the pipe (which is
// shared between parent and child), and the parent behaves as if
// the signal had been raised.
blockUserSignals();
// See #4074. Sometimes fork() gets interrupted by the timer
// signal and keeps restarting indefinitely.
stopTimer();
int pid = fork();
switch(pid)
{
case -1:
unblockUserSignals();
startTimer();
case 0:
...
unblockUserSignals();
...
default
...
unblockUserSignals();
...
So it gets blocked in the parent process's thread before fork() and then gets unblocked again in the parent and child processes later.
This is not wrong. But surely there is a less complicated solution: block all signals before the fork, have that signal mask be inherited in the child, sort out the shared pipes and then restore the previous signal mask in the child. And similarly restore it in the parent after the fork too. There is no need to be so selective about the signals to be masked. It's rather a close coupling with the RTS, which is fine if it's necessary but here it is not.
Incidentally, it's not immediately obvious to me that the use of unblockUserSignals in the child is in a place that solves the problem that the comment identifies. Surely we need to do something to stop the sharing of the pipe, or something. I don't see anything that resolves the problem before the unblockUserSignals call.
This looks to be related to #384. Not using unblockUserSignals at all would presumably avoid any problem with shared users of unblockUserSignals.
Also related: startTimer and stopTimer are no-ops from GHC 10 and are thus deprecated. The RTS no longer uses signals for its timer. The C functions don't yet have deprecation warnings, but they probably will soon.
- Vorherrschende Sprache
- Haskell
- Sterne
- 91
- Forks
- 93
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus haskell/process
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
-
HAVE_PIPE2 at compile time but not at runtime causes segfault on macOSEvtl. vergeben @alt-romes hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
-
posix_spawn falls back to fork() when create_group = True due to HAVE_DECL_ macro mismatchEvtl. vergeben @lei-jia-xing hat das vor 11 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 57/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Alle Issues in haskell/process
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
haskell/bytestring#730 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
seal-harness/seal-harness#399 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
fmidue/codeworld-tasks#124 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
reflex-frp/reflex#563 ·