Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To catch or not to catch

Tags:

c++

linux

signals

Should application catch "bad" signals such as SIGSEV, SIGBUS?

like image 732
dimba Avatar asked Jan 26 '26 20:01

dimba


1 Answers

Those signals are produced in "should never happen" circumstances, when your program is in an undefined state. If you did catch them, continuing execution would be extremely problemeatic, as it would almost certainly cause more, possibly even more severe, errors. Also, if you don't catch them, the OS may be able to do things like produce useful diagnostics such as core dumps. So I would say "no", unless you don't want the core dump, and your error handling does something very simple such as write to a log and terminate.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!