Spawn new process -> get pid

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Feb 5 00:25:47 EST 2008


On 4 feb, 22:21, breal <hacker.steven... at gmail.com> wrote:
> On Feb 4, 3:34 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
>
> > En Mon, 04 Feb 2008 20:59:16 -0200, breal <hacker.steven... at gmail.com>
> > escribió:
>
> > > I have a soap server written in Python that acts as an intermediary
> > > between a web service and an InDesign server.  The indesign server is
> > > non-threaded, so when all instances are used up I want to create a new
> > > instance, get the pid, use the process, then kill it.
>
> > Use the subprocess module:http://docs.python.org/lib/module-subprocess.html
>
> Thanks for the reply.  Using subprocess.Popen I am able to get and
> kill the process.  However, the process I am running creates another
> process (an instance of InDesign Server) so when I kill the first
> process it doesn't kill the second.  Is there any way to capture both
> PIDs and kill them?

I assume you're on *nix. Can you modify the first process? Make it a
project group leader, then kill the whole group. I don't remember the
details, try `man setpgrp` (or setpg?)

--
Gabriel Genellina



More information about the Python-list mailing list