-
Notifications
You must be signed in to change notification settings - Fork 418
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
Signal processing in user application not possible (c application) #449
Comments
You are aware of this from the doc:
|
log
addition
|
@adrianmiriuta that works for me without any problems: However, I agree that managing all signals should be rather on option to be switched on than off but that would of course now break the behaviour of the library. I also tripped over this as I didn't expect it would catch all signals. @guymcswain, perhaps a solution would be that the signal handler in pigpio really just handles the signals which are registered via the API after a callback handler has been registered and leaves the other ones alone? Also because just now a non-handled signal causes a brutal exit(-1) which made my robot actually crash into a wall because the program terminated instantly. It would be much better in that case just to ignore these signals and let them dealt with the main program in a transparent way. The exit(-1) is surely not a feature which needs to be kept? |
Here is my suggestion to get rid of the exit(-1) issue:
into these two functions so that only those handlers are registered which actually have valid callbacks. Let me know what you think? |
Should add that if the user provides NULL for the callback it can be set back to |
|
I think I'm also not an expert in this area but I'll share my thoughts and observations:
|
|
I see where you are coming from in terms of demon and C level. I think it would be good to talk to the author of pigpio and at least get rid of the exit(-1) issue by just registering signals which are really needed? I think that could be dealt with completely transparently without changing anything (except of not bailing out with exit(-1) )? |
@berndporr Line 5640 in c33738a
|
@berndporr , I'm willing to take small steps to make improvements to the lib. @adrianmiriuta , it sounds to me that you are not acceptable even with these changes. Is that the case?
Please also consider that users don't always do things correctly and that you can leave the system in a horrific state if you don't exit gracefully. I think this may have been an intent from the author. I'm certainly biased to avoiding issues that I have to deal with later as the maintainer of pigpio. |
@guymcswain
|
Firstly, sorry your robot crashed. Can you explain why you were not able to handle the signal after setting bit 10 to the internals configuration register? |
That was before I asked here how to disable signal handling. It works well now. It's rather for other C coders who use signals in their code and then caught by surprise when it exits. Plus in most cases then the setting of the flag to disable signal handling won't be needed so will cause less trouble for both the maintainers and the users. Basically: it's not about me (I can live with it) but making the library as easy to use as possible - so community care! |
I could create a pull request which gets rid of the exit(-1) and only registers the signal handlers which are actually in use. Initially only the ones which deal with the debug level and then the others are registered when a callback has been set for the corresponding signal. |
Go ahead with a PR so I can review exactly the scope of the changes you are proposing. |
The reason signals work the way they do was to ensure the DMA engine was shut down on program failure. I was worried the DMA engine would trash all of user memory and corrupt SD cards. That paranoia led me to exit on any unhandled signal. Nowadays I'd probably take a more relaxed approach and says tevs. |
I see the point that the DMA needs to be stopped at program failure as it's quite a scary mechanism. I agree. I guess that makes a case for catching signals related to a program crash / shutdown and being paranoid here is a good thing. Though the bog standard user & realtime signals are not triggered during shutdown so no need to trigger an exit(-1) here. I'll have a go and create a pull request and take that into account. In this way also less users are forced to switch off the signal handling completely. |
while user app cannot terminate,
This signals should be handled by the main app, not the library.
The text was updated successfully, but these errors were encountered: