ctrl-c and os.system problem

Noom News noomnews at yahoo.com
Tue Apr 2 23:55:47 EST 2002


"Donn Cave" <donn at u.washington.edu> wrote in message news:<a8dbup$hec$1 at nntp6.u.washington.edu>...
> Quoth Noom Knews <noomnews at yahoo.com>:
> | 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
>  ...
> | This was tried on Redhat Linux with python 1.5.2
> 
> NetBSD's system(3) man page explains that system ignores SIGINT
> and SIGQUIT.  I assume the same must be true on Red Hat Linux,
> and Python calls C system().
> 
> Maybe you could use spawnv()?
> 
> 	Donn Cave, donn at u.washington.edu

Thanks!  The strange thing is that SIGINT kill the os.system but was
not propated to kill the whole python process.  This behavior made
python different from perl where the whole process would be killed.

-Nick



More information about the Python-list mailing list