ctrl-c and os.system problem

Noom Knews noomnews at yahoo.com
Tue Apr 2 14:58:40 EST 2002


I have a simple program like this

os.system("ls -lR / > /tmp/ls.out")
print "end"

When I press ctrl-c, the "end" message is still print.
 I'd like to terminate the whole process when pressing
ctrl-c instead of just "end".

I tried to catch the signal already but can't catch
the SIGINT or anything else at all during the
os.system call.   This does not work either

try:
   os.system("ls -lR / > /tmp/ls.out")
   print "end"
except:
   print "get all exception"

This will keep printing "end" when ctrl-c is pressed
too. I think this could be os.system problem. If I use
other statement instead of os.system, the program
works as I expected.

This was tried on Redhat Linux with python 1.5.2

Thanks,
Nick

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://http://taxes.yahoo.com/




More information about the Python-list mailing list