Killing children

Peter Hansen peter at engcorp.com
Fri Aug 6 18:32:35 EDT 2004


Laura Conrad wrote:
>>>>>>"Peter" == Peter Hansen <peter at engcorp.com> writes:
> 
> 
>     Peter> Laura Conrad wrote:
>     >> p = os.spawnl(os.P_NOWAIT, "/usr/bin/python", "python", "hobo.py", '/dev/ttyS0', 5)
>     >> print p
>     >> os.system("ps")
>     >> time.sleep(60)
>     >> os.system("kill %d" % p)
> 
>     Peter> This suggests that you believe the return value from os.spawnl() is
>     Peter> actually the PID.  Unfortunately that doesn't appear to be the case
>     Peter> on Windows.  See the note in the doc-string for my code sample from
>     Peter> the previous post (on Windows spawn* actually returns a "handle",
>     Peter> not the PID itself, and apparently turning the one into the other
>     Peter> is non-trivial).
> 
> So you think os.kill(p) might be the way to kill it?   But does anyone
> know how to get it started right?

Uh... maybe?  I think I just got out of my depth here... is Python
compiled specially for cygwin, or is it the standard Windows Python
that is involved?

If the latter, which I now doubt for some reason, then yes, os.kill()
can kill things spawn with spawnl/v/p/whatever provided that you use
the fake os.kill that I provided before, because os.kill doesn't
normally exist on Windows.

-Peter



More information about the Python-list mailing list