AP_HAL_Linux: RPI: set signal handler iff nobody has already done it before

This commit is contained in:
Staroselskii Georgii 2016-07-13 16:51:44 +03:00 committed by Andrew Tridgell
parent 5e8edcb1db
commit 8d2b587f71
1 changed files with 7 additions and 3 deletions

View File

@ -378,10 +378,14 @@ void RCInput_RPI::set_sigaction()
{
for (int i = 0; i < NSIG; i++) {
//catch all signals (like ctrl+c, ctrl+z, ...) to ensure DMA is disabled
struct sigaction sa;
struct sigaction sa, sa_old;
memset(&sa, 0, sizeof(sa));
sigaction(i, nullptr, &sa_old);
if (sa_old.sa_handler == nullptr) {
sa.sa_handler = RCInput_RPI::termination_handler;
sigaction(i, &sa, NULL);
sigaction(i, &sa, nullptr);
}
}
}