问题描述
- 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
"),
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 :
%s
"), 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
")));
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
解决方案
http://blog.csdn.net/iw1210/article/details/36204429
解决方案二:
ACE学习(八)Reactor模式
----------------------