Closing pipes

Donn Cave donn at drizzle.com
Sun Mar 16 18:08:57 EST 2003


Quoth Tom Chance <tomchance at gmx.net>:
...
| Ah, brilliant, I've got Popen3 working, and I can get the pid. But for some
| reason I can't kill the process! I've tried doing "kill(pid,
| signal.SIGKILL)" and "kill(pid, 0)", but neither work. I've tried closing
| the pipe first with "child.fromchild.close()", and then killing, and that
| doesn't work either. Kill just fails to kill the process.

You might check the process IDs in question - maybe check with "ps" -
to verify that you have the process you want.  You may have just killed
a shell process, for example.  If that's the problem, you might try this:
1.  Set up a signal handler, for SIGTERM.  2. kill(0 - os.getpid(), SIGTERM)
That might work, though only if you started the Python program from the
interactive shell.  Of course in the real world it would very likely be
better to take a second look at what your objectives really are and how
they can be accomplished within the application's normal modes of
interaction, but that isn't our problem here.

	Donn Cave, donn at drizzle.com




More information about the Python-list mailing list