andy当我遇上你 2015-09-09 14:11 采纳率: 25%
浏览 1740

ACE reactor模式里忽略SIGPIPE

I haved googled ,and find 3 methords to ignore SIGPIPE, but they are not work, the 3 methords to ignore SIGPIPE in ACE :

1: ignore SIGPIPE directly in send_function, but it's not work:

int send_function(){
// Ensure an error, not a signal, on broken pipe.
ACE_Sig_Action no_sigpipe ((ACE_SignalHandler) SIG_IGN);
ACE_Sig_Action original_action;
no_sigpipe.register_action (SIGPIPE, &original_action);

.................
peer().send_n(buf, buf_len);
.................

no_sigpipe.restore_action (SIGPIPE, original_action);
}
2: ignore SIGPIPE in the begin of main function, but it's not work:

int main() {
// Ignore SIGPIPE so that each can handle this on its own.
ACE_Sig_Action sig ((ACE_SignalHandler) SIG_IGN, SIGPIPE);
ACE_UNUSED_ARG (sig);

......
}
3:Try to fetch SIGPIPE signal with ACE handler_signal(), but it's not work:

ACE_Sig_Set sig_set;
sig_set.sig_add(SIGINT);
sig_set.sig_add(SIGQUIT);
sig_set.sig_add(SIGSEGV);
sig_set.sig_add(SIGPIPE);

if (ACE_Reactor::instance()->register_handler(sig_set, this) == -1)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("%p\n"),
ACE_TEXT("register_handler")),
-1);

  ...

handle_signal function:
int XXX::handle_signal(int signum, siginfo_t *,ucontext_t *)
{
if( SIGPIPE== signum ){
ACE_Stack_Trace st;
ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%P|%D) stack : \n%s\n"), st.c_str()));
ACE_Sig_Set sig_set;
sig_set.sig_add(SIGSEGV);
ACE_Reactor::instance()->remove_handler(sig_set);
}
ACE_Reactor::end_event_loop();

ACE_DEBUG((LM_DEBUG,ACE_TEXT("(%P|%D) end event loop\n")));
return 0;
}
the SIGPIPE can't be fetched in handle_signal().

I have try this 3 methords, but they are not work.

can only one help me?

请各位大侠帮帮忙,小弟现在想把ACE中发生的SIGPIPE信号忽略处理,百度了也说这三种方法不可行,请高手指点,先谢谢了!
http://stackoverflow.com/questions/27894269/ace-set-ignore-sigpipe-is-not-work

  • 写回答

1条回答 默认 最新

  • devmiao 2015-09-09 15:13
    关注
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面