Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The SIGBUS signal can be received when errors occur during reads/writes from mmap'ed device files. This branch adds the
SigBusGuard
class, which implements a signal handler that will throw aSigBusError
exception whenever SIGBUS is received. Theipbusmmap-2.0
client was also updated to protect against SIGBUS with this class.Intended usage: An instance of
SigBusGuard
class should be created before any set of reads/writes from the mmap'ed device file, and the reads/writes themselves should be implemented in a std::function/lambda that's passed to the protect method, along with a message which will be used for the exception that's thrown. I.e:Note: The SIGBUS signal handler is only defined for the lifetime of the
SigBusGuard
instance, and to ensure the the signals are handled by the appropriate thread a static mutex is is locked in theSigBusGuard
contructor and unlocked in the destructor. As a result only oneSigBusGuard
instance can be alive at any given time, and so a deadlock will occur if e.g. the user were to attempt to create multiple instances in a single function, e.g: