The other solutions I can think of are likely heavier and harder than arranging to spawn the child without shell=1 - so I'd suggest tackling that.

Or *maybe* - you could do something like spawning a thread in the child process to read from stdin - that's likely to block until the cmd.exe parent is killed, in which case the read would return with an error - at which point the child could terminate itself...

Mark

On 19/06/2013 7:51 AM, Patrick Tisdale wrote:
Hello list,
I have written a test script to run as a service.  The service starts up
properly, and spawns a subprocess (called test.py) using
subprocess.Popen.  However, I am having no luck killing the subprocess
when I stop the service.  I am using os.kill()

It works fine when running pythonservice.exe in debug mode.  But when I
start it using "net start" the subprocess.Popen.pid matches the "cmd"
that it spawns (due to shell=True, I suppose).  I have tried it without
shell=True, but can't get the script to run without it.


The test script is a simple script that periodically writes to a file.
The script that I actually need to make work is a twisted twistd (.tac)
file, which will have multiple TCP connections open, and I need to be
able to close those connections before it exits.

Any ideas on what I'm missing?

Thanks,
Patrick Tisdale


_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to