How can I run a command from a python script and delegate to it signals like Ctrl+C
?
I mean when I run e.g:
from subprocess import call
call(["child_proc"])
I want child_proc
to handle Ctrl+C
How can I run a command from a python script and delegate to it signals like Ctrl+C
?
I mean when I run e.g:
from subprocess import call
call(["child_proc"])
I want child_proc
to handle Ctrl+C
I'm guessing that your problem is that you want the subprocess to receive Ctrl-C and not have the parent Python process terminate? If your child process initialises its own signal handler for Ctrl-C (SIGINT) then this might do the trick:
Now you can hit Ctrl-C (which generates SIGINT), Python will ignore it but
less
will still see it.However this only works if the child sets its signal handlers up properly (otherwise these are inherited from the parent).