aleax at aleax.it
Sun Mar 16 17:08:35 CET 2003
Tom Chance wrote:
>> You would kill the process with the kill() function (posix or os.kill())
>> It sends your choice of signal to the process; you might use SIGTERM.
> But to use the kill() function I need to know the process ID of the pipe,
> and afaik popen() doesn't return that, and neither does fork(). How can I
> get the pid?
os.fork() does return the child's process ID *to the parent*, and 0 to
the child. So, the parent can indeed know the child's PID if your code
chooses to use os.fork(). The various os.spawn...() functions also
return the child'd PID when called with os.P_NOWAIT.
popen2.Popen3 (the _class_ -- NOT to be confused with the _function_
in the same module, which is [sigh] spelled with a lowecase initial)
instances have a .pid attribute, and so do instances of class Popen4
in the same module.
More information about the Python-list