killing a script
russ.paielli at gmail.com
Sun Aug 28 22:41:25 EDT 2011
On Aug 28, 6:52 pm, MRAB <pyt... at mrabarnett.plus.com> wrote:
> On 29/08/2011 02:15, Russ P. wrote:> I have a Python (2.6.x) script on Linux that loops through many
> > directories and does processing for each. That processing includes
> > several "os.system" calls for each directory (some to other Python
> > scripts, others to bash scripts).
> > Occasionally something goes wrong, and the top-level script just keeps
> > running with a stack dump for each case. When I see that, I want to
> > just kill the whole thing and fix the bug. However, when I hit Control-
> > C, it apparently just just kills whichever script happens to be
> > running at that instant, and the top level script just moves to the
> > next line and keeps running. If I hit Control-C repeatedly, I
> > eventually get "lucky" and kill the top-level script. Is there a
> > simple way to ensure that the first Control-C will kill the whole darn
> > thing, i.e, the top-level script? Thanks.
> You could look at the return value of os.system, which may tell you the
> exit status of the process.
Thanks for the suggestion. Yeah, I guess I could do that, but it seems
that there should be a simpler way to just kill the "whole enchilada."
Hitting Control-C over and over is a bit like whacking moles.
More information about the Python-list