Catch Segfault or any other errors/exceptions/signals in C++ like catching exceptions in Java

前端 未结 5 1489
长情又很酷
长情又很酷 2020-12-11 03:43

I wrote a Linux program based on a buggy open source library. This library sometimes triggers segfaults that I cannot control. And of course once the library has segfaults,

5条回答
  •  遥遥无期
    2020-12-11 04:10

    You cannot reliably resume execution after a segmentation violation. If your program must remain running, fence off the offending library in a separate process and communicate with it over a pipe. When it takes a segmentation violation, your program will notice the closed pipe.

提交回复
热议问题