[Tutor] popen2.Popen4 objects

klappnase klappnase@freenet.de
Mon Aug 4 20:00:04 EDT 2003


Thank you so much!

Meanwhile I found another problem.
If I create an instance of Popen4 and want to get the PID of the child process with:

     self.pp = popen2.Popen4(cmd)
     cmdpid = self.pp.pid

the PID that is returned belongs not actually to the process that I am interested in, but to
a subshell and the PID I wanted is cmdpid + 1.
This is a problem if I want to abort the child process with

     os.kill(self.pp.pid, 9)

I found that the subshell is being killed but the child process is happily running on.
I might use instead

     os.kill(self.pp.pid+1, 9)

but I am not sure if I can rely on the PID of the child to be exactly the subshell's PID + 1.
I might use os.system("skill -KILL cmd") instead, but I thought there must be a "Python way" to do this.
Can anyone help with this problem?

Thanks in advance

Michael





More information about the Tutor mailing list