boostorg / boostorg/interprocess

Semaphore use in signals

Offen
#262 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
185
Forks
131
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I am using interprocess' semaphore in conjunction with timed_wait, and I need to be able to handle SIGINT to terminate the waiting early. Looking into the implementation, I can see that I am getting the spin semaphore internally, which suggests to me that `post()`ing it from the signal handler is safe, since it is effectively just an atomic increment.

This would likely not hold in other types of internal implementations of the semaphore. For example, while POSIX implementation seems to be fine in the first line (it just uses `sem_post`), it can later throw an exception.

This leads me to two thoughts:

1. Can we have a variant of the POSIX post() that would not throw an exception?
2. Can we add compile-time introspection for signal safety of the chosen semaphore implementation? So that one can do something like `static_assert(boost::interprocess::interprocess_semaphore::signal_safe_post)`.

I am happy to contribute such improvements if there's a consensus.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Es wird keine Datei oder kein Test genannt. Beginne damit, die von interprocess_semaphore verwendeten Semaphore-Implementierungen nachzuverfolgen, insbesondere die Spin- und POSIX-Pfade, und wie timed_wait mit SIGINT interagiert. Als erledigt gilt die Aufgabe, wenn das Projekt ein festgelegtes Design für ein keine Exceptions auslösendes POSIX post und Informationen zur Signalsicherheit zur Compile-Zeit hat.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
operating-systems
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.