英文:
How to handle a shared lib calling exit() and unexpectedly destroying global objects?
问题
一个应用程序使用librpm.so
,它通过调用exit()
来处理一些错误,例如当它接收到SIGPIPE信号时。这导致glibc在其他线程正在访问它们时销毁本地静态对象,从而导致崩溃。
在glibc开始销毁静态实例之前,是否有一种方法可以让应用程序进行清理(取消初始化使用线程的模块)?这些模块是从编译后的共享库中启动的。
英文:
An application uses librpm.so, which handles some errors by calling exit()
, for example when it receives a SIGPIPE. This results in glibc destroying local static objects while other threads are accessing them, resulting in a crash.
Is there a way for the application to clean up (uninitialize modules that use threads) before glibc starts destroying static instances ? These modules are started from compiled shared libraries.
答案1
得分: 1
你可以主动捕获 SIGPIPE 信号,然后再库处理之前。
示例:https://www.thegeekstuff.com/2012/03/catch-signals-sample-c-code/
英文:
You can be proactive a catch SIGPIPE before the library takes it.
Example: https://www.thegeekstuff.com/2012/03/catch-signals-sample-c-code/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论