Closing pipes

Tom Chance tomchance at
Sun Mar 16 11:37:03 CET 2003

Donn Cave wrote:

> Quoth Tom Chance <tomchance at>:
> | I've got a bit of code that opens a new pipe with os.popen, to start
> | mencoder. When I call the close() function on it, it takes an
> | unacceptably long time to close the pipe and return to the main thread.
> |
> | I've tried using popen2.popen2 to open and close the thread, and this
> | will close the thread instantly, but rather than killing the process, it
> | simply seems to detach itself from the thread and return python to its
> | main thread.
> |
> | Is it simply an unavoidable feature of python and its pipe support that
> | it will take quite a while to kill a process? Is there any way I can
> | kill the process more quickly?
> 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?


More information about the Python-list mailing list