try/catch segment fault 的第三方类库

segvcatch

 

About

This is a crossplatform C++ library designed to convert a hardware exceptions, such as segmentation fault, or floating point errors, into a software language exceptions, which can be handled later with a try/catch construction.

Other words, it's a crossplatform structured exception handling (SEH).

For example, this code is working fine:

try
{
   
*(int*)0=0;
}
catch(std::exception& e)
{
    std
::cerr <<"Exception catched : "<< e.what()<< std::endl;
}

不错,经测试,可以用。
但是有些心虚,应为毕竟segment fault 之后,堆栈就已经被破坏了。。。 
posted @ 2012-03-14 23:29  王帅901  阅读(733)  评论(0编辑  收藏  举报