Closing pipes
Tom Chance
tomchance at gmx.net
Sun Mar 16 05:37:03 EST 2003
Donn Cave wrote:
> Quoth Tom Chance <tomchance at gmx.net>:
> | 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?
Tom
More information about the Python-list
mailing list