Skip to content

在自定义的信号处理函数中是否有必要兼容其他的信号处理函数呢 #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lxzh opened this issue Nov 22, 2019 · 2 comments
Labels
question Further information is requested

Comments

@lxzh
Copy link

lxzh commented Nov 22, 2019

我看Tencent Bugly里面会对其他信号处理进行兼容:

static void my_handler(const int code, siginfo_t *const si, void *const sc) {
...  
  /* Call previous handler. */  
  old_handler.sa_sigaction(code, si, sc);  
}

参考他们的文章:https://zhuanlan.zhihu.com/p/27834417

某些信号可能在之前已经被安装过信号处理函数,而sigaction一个信号量只能注册一个处理函数,这意味着我们的处理函数会覆盖其他人的处理信号
保存旧的处理函数,在处理完我们的信号处理函数后,在重新运行老的处理函数就能完成兼容。

所以在xcd_core_signal_handler里是否需要回调旧的信号处理函数呢?

@caikelun
Copy link
Collaborator

xCrash 默认会恢复上一个注册的 signal handler,处理方式和 bugly 是一样的,恢复的逻辑在这里:
https://github.com/iqiyi/xCrash/blob/master/src/native/libxcrash/jni/xc_crash.c#L407

如果不希望恢复之前的 signal handler,可以在初始化的时候设置 setNativeRethrow(false)

@caikelun caikelun added the question Further information is requested label Nov 22, 2019
@lxzh
Copy link
Author

lxzh commented Nov 22, 2019

好的,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants