-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Describe the Bug
Because quit_controller gets registered as the signal handler for SIGINT it becomes impossible to use normal cleanup code for a python process (and presumably similar in other languages).
Steps to Reproduce
- Write a python script using any controller that tries to do cleanup using
try ... finallyoratexit - Run the script
- Try to end it with CTRL+C
- The script exits without executing the finally.
Expected behavior
Webots should not be fully overwriting the signal handler, or at the very least provide an option to not do that. I am honestly not even sure what the point of this code is. The only interesting detail is that a global variable gets set that however AFAICT is not used anywhere.
If this code is for some reason necessary it would be great if this could at least be documented clearly.
System
- Operating System: Linux Ubuntu 24.04
- Graphics Card: Irrelevant
Additional context
Luckily the init code is only executed once and it's possible to overwrite the signal handler back to the python default via signal.signal(signal.SIGINT, signal.default_int_handler), so that's a functional workaround for now. This works perfectly, it doesn't appear that the controller API needs any cleanup done that is disabled by this.