- 论坛徽章:
- 0
|
main.c
主loop里面有
handle_events()
{
struct timeval timo;
kill_link = open_ccp_flag = 0;
if (sigsetjmp(sigjmp, 1) == 0) {
sigprocmask(SIG_BLOCK, &signals_handled, NULL);
if (got_sighup || got_sigterm || got_sigusr2 || got_sigchld) {
sigprocmask(SIG_UNBLOCK, &signals_handled, NULL);
} else {
waiting = 1;
sigprocmask(SIG_UNBLOCK, &signals_handled, NULL);
wait_input(timeleft(&timo));
}
}
waiting = 0;
calltimeout();
if (got_sighup) {
info("Hangup (SIGHUP)");
kill_link = 1;
got_sighup = 0;
if (status != EXIT_HANGUP)
status = EXIT_USER_REQUEST;
}
if (got_sigterm) {
info("Terminating on signal %d", got_sigterm);
kill_link = 1;
asked_to_quit = 1;
persist = 0;
信号处理里面是
static void
term(sig)
int sig;
{
/* can't log a message here, it can deadlock */
got_sigterm = sig;
if (conn_running)
/* Send the signal to the [dis]connector process(es) also */
kill_my_pg(sig);
notify(sigreceived, sig);
if (waiting)
siglongjmp(sigjmp, 1);
}
而got_sigterm是全局变量,没有声明成volatile
我的想法是有没有可能在主循环里面got_sigterm被编译优化到寄存器里面,这样的话就有话就算信号处理里面改掉,主循环感知不到呢。
但目前来讲从来没发生这种情况。我的问题就是全局变量编译一般会不会有寄存器变量。 |
|