<font color="#000000"><br></font><br><div class="gmail_quote">On Sun, Aug 28, 2011 at 10:41 PM, Russ P. <span dir="ltr"><<a href="mailto:russ.paielli@gmail.com">russ.paielli@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><div class="im">> You could look at the return value of os.system, which may tell you the<br>
> exit status of the process.<br>
<br>
</div>Thanks for the suggestion. Yeah, I guess I could do that, but it seems<br>
that there should be a simpler way to just kill the "whole enchilada."<br>
Hitting Control-C over and over is a bit like whacking moles.<br></blockquote><div><br>Agreed.  I had written a program that had a similar problem.  As others have suggested, you need to either wrap os.system in another function that analyzes the return value of the call or use another approach in which the Python program itself sees the SIGINT (I ended up changing to subprocess.Popen classes since they are more customizable and SIGINT is captured by the Python program itself rather than the child process).<br>
<br>Another thing you can consider doing is to define your scripts' behavior if it captures a SIGINT.<br><br>(Untested)<br><br>import signal, sys<br><br>def sigint_handler():<br>    sys.stdout.write('Caught an interruption signal!')<br>
    sys.exit(1)<br><br>signal.signal(signal.SIGINT, sigint_handler)<br><br>**rest of your program**<br><br>Of course, the SIGINT signal won't be caught if it isn't seen by the main Python process, so this still won't do anything if you use an unprotected/unwrapped os.system command.<br>
<br>HTH,<br>Jason<br>
</div></div>