-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gpioTerminate() leaves signal handlers installed #341
Comments
Is there a particular problem that you are trying to solve and is there a proposed solution that you have tested? |
I have a little project on a Pi Zero. I use libgpiod for processing the gpio lines going from 0 to 1 and reverse, but because libgpiod has no support (for kernel 4.x that is) for changing the PullUp/PullDown resistors, I initialize these with pigpio. I use pigpio because this project is alive and being maintained. Pseudo code:
When you compile the 'code' in a console project (I run the Pi headless), then run the executable and press Ctrl-Z during the sleep() (to pause the program), the signalhandler of pigpio will step in, tell you that the signal is not being handled and terminate the program.
In my humble opinion, because it's not that I want to criticize anyone or anything, this leaves some questions:
When you say: "Not many people are using pigpio for such a brief time, but for the full duration of their program, so probably gpioTerminate() will only be called just before terminating their whole program, if it will be called at all", you are right. I agree with you that solving question 1 is not very useful or important for most people. Implementing the code I suggested would only be a matter of correctness or politeness. I think that the issue I report is not very well described. In hindsight is should be: 'Pressing Ctrl-z while using pigpio terminates the running process' . I hope this clarifies my issue. |
Thanks for the additional background. My questions were aimed at 'what is it that want implemented' - you gave multiple choices - and 'how to know it is working'. Also, have you done any research on the history of issues relating to signal handling on this repo. I'm asking because I'm not an expert in this area and you seem to be more knowledgeable. I do know that an option to turn off signal handling was implemented. Don't know if you experimented with that. |
I have missed this one. Can you point out to me how to accomplish this? By the way: For my own project I've multiple workarounds: e.g. I could save the signal handlers before initializing pigpio and restore them after terminating pigpio. I could leave pigpio altogether (for this project that is) and use the bcm2835 library from Mike McCauley, just for doing the same thing as I used pigpio for. Another workaround would be to 'install' the PullUp resistors at boot time in the /boot/config.txt, so I'm not desperate :-). With regards to doing research: What I can find about this issue is that quite some people are fighting this issue, so that brings me back to question 2, but it is not my intention to corner you about this issue. |
The api is
Yes and if you read all the related threads you'll find that Joan defends the rationale behind the implementation. I can't remember but it has something to do with the daemonization process. |
Nice. I just did the same. I agree with you: PI_CFG_NOSIGHANDLER, but officially gpioCfgInternals() is deprecated and one should use gpioCfgSetInternals(). For all I can see in the code gpioCfgInternals() will only handle to distinct settings. But all in all: There is some means of escape when the signal handling is bothering someone, so as far as I'm concerned, we can close this issue. For a daemonized version it makes sense. Signals sent to the using program will never get to the daemon. For the library version one could use PI_CFG_NOSIGHANDLER. |
I'll try to remember to update the doc and remove deprecated APIs for the next release. |
That would be a good thing to do. Maybe some clarification for non-daemon users also? By the way, I can confirm next code works:
As you reopened this, I think you close this one? |
@frank1119 , Can you please test the latest commit on the repo's wget https://github.com/joan2937/pigpio/archive/develop.zip
unzip develop.zip
cd pigpio-develop
make
sudo make install Update: Ignore this for now, error compiling. Sorry. |
Ok, the latest commit on the Note, the patch under test addresses issue #220. Now that I re-read your description they are probably not related. |
I think you mix up issue #220 with this one, although I grant you that the underlying issue is rather alike. Still, I've tested your commit https://codeload.github.com/joan2937/pigpio/zip/develop. That didn't compile, but to check whether there was a change in the behavior, I fixed the _exit() errors myself. But after that, the behavior for issue #341 didn't change (not completely unexpected). |
Thanks, I think I need some sleep. |
After calling gpioTerminate() the signal handlers are still installed. Maybe something like this should be done afterwards to cleanup?
Or, maybe a lot better:
The text was updated successfully, but these errors were encountered: