c++ - I want to know which a signal is arrived when system call() is interrupted -
my application has 2 threads. each threads recevive data server via each sockets. threads wait return epoll_wait(). epoll_wait() returns -1 , errno eintr. eintr means system call() interrupted signal. added process eintr. not know signal arrived , why signal arrived. wonder it.
method 1.
i created thread.
sigset_t smaskofsignal; sigset_t soldmaskofsignal; sigfillset(&smaskofsignal); sigprocmask(sig_unblock, &smaskofsignal, &soldmaskofsignal) while(1) { sigwait(&smaskofsignal, &sarrivedsignal); fprintf(stdout, "%d(%s) signal caught\n", sarrivedsignal, strsignal(sarrivedsignal)); }
i not catch signal when epoll_wait() interrupted.
method 2
when execute application in strace tool, epoll_wait() never interrupted.
my problem reproduced in gdb tool. need helps....
you can try implement own signal handler. if application gets interrupted signal again, own signal-handler called , can see, kind of signal has been raised.
void signal_callback_handler(int signum) { printf("caught signal %d\n",signum); exit(signum); // terminate application } int main() { // register signal handler signals want handle signal(sigint, signal_callback_handler); signal(sigabrt, signal_callback_handler); signal(sigsegv, signal_callback_handler); // .. , more, if want }
not handy-method, should (hopefully) enable find out, signal has been raised. take here see different signals, can handled (note: not signals can handled in own signal-handler(!)).
Comments
Post a Comment