Problem solved but not by assigning other keyboard signals;
The underlying problem, which I tried to distill as much as possible to make the post as small as possible, is that my code uses subprocess.Popen to start up raspivid. Hitting Ctrl-C for my code is caught in a signal handler and does "stuff". Sadly, it's also passed to raspivid as my child, which stops videoing.
Hence this question was about changing the signal sent to my code to do "stuff" without stopping raspivid.
I couldn't daemonize it simply by setting the subprocess.Popen command line to end with "&" - it moaned at that.
But then I discovered the preexec_fn for subprocess.Popen which allowed me to call os.setpgrp() in the preexec_fn, thus separating raspivid from my code's group, and therefore Ctrl-C doesn't get forwarded to raspvid. I can still send raspivid SIGINT in my code when I want to stop the videoing by doing
Code: Select all
def daemonize():
os.setpgrp()
raspivid_proc = subprocess.Popen(["raspivid", "-o", "video_file_name", "-t", "0"], preexec_fn = daemonize)
....
raspivid_proc.send_signal(signal.SIGINT)
Thanks for the suggested solutions to the distilled problem I described.