0

Browsing the internet, I found the only solution: throw an exception from a signal handler and use -fnon-call-exceptions. At the same time, this is considered illegal. Some people advise to patch the stack frame to throw an exception on the return from a signal handler, but this is not cross-platform.

Is there any alternative to POSIX signals and related API for that in Linux that does work on all Linux platforms and is legal?

Roman Maltsev
  • 307
  • 1
  • 3
  • 9
  • 3
    Exceptions have scope defined (try-catch),Segment faults scope for whole program. How do you plan to throw exception with correct stack trace? Frankly for too many reasons, this is not good idea – Mahesh Attarde Dec 05 '19 at 08:31
  • Maybe you can also find inspiration in [this question](https://stackoverflow.com/questions/10202941/segmentation-fault-handling). – Lukas-T Dec 05 '19 at 08:45
  • 1
    I can't think of a single sane reason, why you'd want to do that. In an case: Since segmentation faults are already platform specific, surely it's impossible to make this cross platform. The whole "throw exception on return from signal handler" would be my approach as well if I had to do something like this. – Voo Dec 05 '19 at 08:54

0 Answers0