Comments (4)
Code? It could be that Ctrl+C is quitting because it has nothing else to run? Post your code and I will review it. Might be a similar problem to mine ( os.kill(PID, signal.SIGINT) will kill PWM aswell and shut main program down ).
from rpio.
I must produce separate example case for this. The problem occurs in a slightly larger code that is not open (yet). Practically there are other threads running and in main thread i have this try KeyboardException that should handle ctrl+c cleanly (and will shut down other threads cleanly as well). If this is not enough, I try to figure out simple an small code for you next weekend.
from rpio.
This is caused by source/c_pwm/pwm.c trapping all signals:
// 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 won't argue the importance of shutting down the DMA engine, but I'd like to think there's a better way of handling it (maybe be a little more discriminating? Only trap signals that would normally be fatal that don't already have handlers?).
This bit me in a different way. I have a server that's just quietly running in a tmux window. That is, until I change it's window size. A window size change sends a SIGWINCH to the process. It would normally be ignored (what care I for window sizes?), but setup_sighandlers() thinks the sky is falling when the window size changes and shuts down my server.
@tuomas2 what you can do is save the SIGINT handler and restore it afterwards. For example:
import signal
saveintsig=signal.getsignal(signal.SIGINT)
# then do the PWM setup
...
# after PWM has been setup...
signal.signal(signal.SIGINT, saveintsig)
try:
doyourstuff()
except KeyboardInterrupt:
sys.exit(0)
from rpio.
I think setup_sighandlers should only handle signals 1-32. 33 onwards are realtime signals. The following whitelist are safe to ignore, they don't terminate the process or are handled by Python
SIGCHLD
SIGCONT
SIGTSTP
SIGTTIN
SIGTTOU
SIGURG
SIGWINCH
SIGPIPE (by Python)
SIGINT (by Python)
SIGIO
from rpio.
Related Issues (20)
- RPIO ver.2 HOT 1
- Input function doen't work
- System hangs during reboot with RPIO python script running in docker HOT 1
- SystemError: This module can only be run on a Raspberry Pi! HOT 4
- Raspberry CM3 module unsupported. HOT 1
- Debian buster need #include <sys/sysmacros.h> inside pwm.c
- After upgrading to buster branch v2 stops working HOT 1
- Uncaught Error: Cannot find 'rpio'
- RPI 4 Model HOT 1
- RuntimeError: This module can only be run on a Raspberry Pi! HOT 2
- SystemError: This module can only be run on a Raspberry Pi!
- _PWM.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: makedev HOT 4
- how disable debbug ?
- RPIO-0.10.0-py3.5-linux-armv7l.egg SystemError: This module can only be run on a Raspberry Pi! HOT 1
- Interrupted by signal 11: SIGSEGV
- mmap check
- System error
- Problem running RPIO on Raspberry Pi 4 HOT 2
- RPIO won't run on my Raspberry Pi 4, how to remove? HOT 1
- https://pythonhosted.org/RPIO/#installation seems outdated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpio.