I have a Python program and when I exit the application with Ctrl-c, the script does not close. My process still shows in running processes.
#!/
I was unable to kill my python sub process because I had set the shell=True
option in the process.Popen
command. I removed shell=True and then I could kill it.
If the subprocess is a shell, then you will have to kill the things it is running before the shell will end itself.
You need to make the thread a daemon thread. To do this add the following line after you call the Thread's init
self.setDaemon(True)
A program will exit when only daemon threads are left alive, the main thread is non-daemonic of course
the_thread.setDaemon(true)
, see http://docs.python.org/library/threading.html#threading.Thread.daemon