ctrl-c and os.system problem

Andrei Kulakov ak at silmarill.org
Tue Apr 2 15:21:50 EST 2002


In article <mailman.1017777544.11640.python-list at python.org>, Noom Knews wrote:
> 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.
>
So os.exec works fine? Use that then.

> 
> 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/
> 


-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org



More information about the Python-list mailing list