AP_HAL_Linux: RCInput_RPI: ignore unwanted signals

We are setting a termination handler for some signals which are of not
interest.  Just ignore them.  Ignoring SIGWINCH allows for example to
run on a screen and change the window size later without killing
ardupilot.
This commit is contained in:
Lucas De Marchi 2017-05-22 14:08:57 -07:00 committed by Andrew Tridgell
parent e803045d1f
commit ee0f46e3aa
1 changed files with 16 additions and 5 deletions

View File

@ -374,12 +374,23 @@ void RCInput_RPI::init_DMA()
// We must stop DMA when the process is killed
void RCInput_RPI::set_sigaction()
{
for (int i = 0; i < NSIG; i++) {
// catch all signals to ensure DMA is disabled - some of them may
// already be handled elsewhere in cases we consider normal
// termination. In those cases the teardown() method must be called.
struct sigaction sa, sa_old;
memset(&sa_old, 0, sizeof(sa));
memset(&sa, 0, sizeof(sa));
/* Ignore signals */
sa.sa_handler = SIG_IGN;
sigaction(SIGWINCH, &sa, nullptr);
sigaction(SIGTTOU, &sa, nullptr);
sigaction(SIGTTIN, &sa, nullptr);
/*
* Catch all other signals to ensure DMA is disabled - some of them may
* already be handled elsewhere in cases we consider normal termination.
* In those cases the teardown() method must be called.
*/
for (int i = 0; i < NSIG; i++) {
sigaction(i, nullptr, &sa_old);
if (sa_old.sa_handler == nullptr) {