Android:捕获 SIGSEGV 信号 JNI
我正在使用 tesseract 项目将图像转换为字符串。 然而,SIGSEGV 信号是从 JNI 发送的(随机?)。
我想在发送信号时重新启动我的应用程序,但我没有找到任何解决方案来使用 Java“捕获”信号。
有人有建议吗?
谢谢
I am using tesseract project to convert image to string.
However, SIGSEGV signal is sent (randomly ?) from he JNI.
I wanted to restart my app when the signal is sent, but I didn't find any solution to "catch" the signal with Java.
Anyone have suggestions ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然您可以使用本机信号处理程序捕获 SIGSEGV,但您可能会发现在处理程序内执行与 android api 交互相关的任何有用操作并不容易。
也许最好的办法就是理解并解决问题。
就解决方法而言 - 这确实是一个非常糟糕的解决方案 - 您可能可以使用 AlarmManager 在未来几秒钟内设置一个事件,然后取消它/如果您在“有风险的事件”之后仍然在运行,则取消它/将其进一步推迟“ 手术。或者您可以启动一个服务(不在同一进程中运行),如果服务连接丢失,该服务将重新启动您的应用程序。
While you can catch SIGSEGV with a native signal handler, you may not find it very easy to do anything useful in terms of android api interaction from within the handler.
Probably the best thing to do is to understand and fix the problem.
In terms of workaround - and that's really a very inferior solution - you could presumably either use AlarmManager to set an event a few second in the future, and cancel it/push it further out if you turn out to still be running after the "risky" operation. Or you could launch a service (not running in the same process) which would restart your application if the service connection is lost.
既然没有人帮忙。我想指出,质疑意图或目标是不尊重的行为。我们需要事实,而不是意见或猜测。这似乎是这里的习惯。就我而言,我想捕获 SIGSERV,因为我想检测共享库中的漏洞。出于安全原因,没有其他可靠的方法可以在不出现误报的情况下检测上述漏洞。这是我几天前发现的东西:
Since no one is helping. I would like to point out the fact that questioning the intention or goal is disrespectful. We want facts, not opinions or speculation. That seems to be a habit here. In my case I want to catch SIGSERV because I want to detect a vulnerability in a shared library. For security reasons, there is no other sure way to detect said vulnerability without welcome false-positives. Here is something I found a couple of days ago: