Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

PWM traps all signals, even those normally ignored #24

Open
mlv opened this issue Mar 27, 2014 · 2 comments
Open

PWM traps all signals, even those normally ignored #24

mlv opened this issue Mar 27, 2014 · 2 comments

Comments

@mlv
Copy link

mlv commented Mar 27, 2014

I have a server that just sits quietly in a tmux window, watching pins and doing it's thing. But if I attach it and my window size changes, it dies. The reason is that source/c_pwm/pwm.c traps all signals, even those that are normally ignored:

// Catch all signals possible - it is vital we kill the DMA engine
// on process exit!
static void
setup_sighandlers(void)
{
    int i;
    for (i = 0; i < 64; i++) {
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = (void *) terminate;
        sigaction(i, &sa, NULL);
    }
}

I believe #19 and #15 are really this bug. But I put this here because the bug is more general than those issues.

@festlv
Copy link

festlv commented May 21, 2014

I helped to debug a similar issue for a friend and arrived at similar conclusion.

I'm not that deep into writing C modules for python, but there has got to be a way to register C function which is being called when python interpreter quits.

Otherwise this behaviour at least has to be documented and workaround (see @mlv's comment on #19) should be provided to ignore legitimate signals- WINCH is just one of the signals whose default action is not to terminate.

@maroc81
Copy link

maroc81 commented Aug 31, 2014

I've also been bitten by this issue. My python application would randomly exit with no output or any indication why. I was finally able to consistently reproduce and it and traced it down to this issue.

My application has a number of threads so SIGCHILD would get sent by the children threads whenever they were interrupted. This seems to be another signal that by default should be ignored.

I'm really surprised that the author didn't catch this or even did it in the first place. The rest of his code works great. I wouldn't be able to do my project on the pi without since the pi only has one pwm.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants