irqbalance signal handling tuning
Added sigaction for SIGTERM, SIGUSR1 and SIGUSR2 using the same handler like SIGINT, i.e. stop and cleanup after finishing of current balancing iteration. Signed-off-by: Petr Holasek <pholasek@redhat.com>
This commit is contained in:
parent
6ae5196bc3
commit
a37e7a0ab1
33
irqbalance.c
33
irqbalance.c
|
@ -238,6 +238,15 @@ static void force_rescan(int signum)
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
struct sigaction action, hupaction;
|
||||
sigset_t sigset, old_sigset;
|
||||
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset,SIGINT);
|
||||
sigaddset(&sigset,SIGHUP);
|
||||
sigaddset(&sigset,SIGTERM);
|
||||
sigaddset(&sigset,SIGUSR1);
|
||||
sigaddset(&sigset,SIGUSR2);
|
||||
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
parse_command_line(argc, argv);
|
||||
|
@ -290,11 +299,6 @@ int main(int argc, char** argv)
|
|||
HZ = 100;
|
||||
}
|
||||
|
||||
action.sa_handler = handler;
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_flags = 0;
|
||||
sigaction(SIGINT, &action, NULL);
|
||||
|
||||
build_object_tree();
|
||||
if (debug_mode)
|
||||
dump_object_tree();
|
||||
|
@ -324,6 +328,20 @@ int main(int argc, char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
action.sa_handler = handler;
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_flags = 0;
|
||||
sigaction(SIGINT, &action, NULL);
|
||||
sigaction(SIGTERM, &action, NULL);
|
||||
sigaction(SIGUSR1, &action, NULL);
|
||||
sigaction(SIGUSR2, &action, NULL);
|
||||
|
||||
hupaction.sa_handler = force_rescan;
|
||||
sigemptyset(&hupaction.sa_mask);
|
||||
hupaction.sa_flags = 0;
|
||||
sigaction(SIGHUP, &hupaction, NULL);
|
||||
|
||||
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
|
||||
|
||||
#ifdef HAVE_LIBCAP_NG
|
||||
// Drop capabilities
|
||||
|
@ -337,11 +355,6 @@ int main(int argc, char** argv)
|
|||
parse_proc_interrupts();
|
||||
parse_proc_stat();
|
||||
|
||||
hupaction.sa_handler = force_rescan;
|
||||
sigemptyset(&hupaction.sa_mask);
|
||||
hupaction.sa_flags = 0;
|
||||
sigaction(SIGHUP, &hupaction, NULL);
|
||||
|
||||
while (keep_going) {
|
||||
sleep_approx(SLEEP_INTERVAL);
|
||||
log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n");
|
||||
|
|
Loading…
Reference in a new issue