signal through popen2

Michael Hudson mwh at python.net
Mon Feb 11 09:23:18 EST 2002


llchen223 at hotmail.com (Lei Chen) writes:

> Hi,
> 
> I would like to send a CTRL-C on a process opened by popen2.  Is
> this possible?

Not as such, as you don't know it's PID.  You could try:

def popen2pid(cmd, bufsize=-1, mode='t'):
    inst = Popen3(cmd, 0, bufsize)
    return inst.fromchild, inst.tochild, inst.pid

(Assuming unixoid systems).

There might be some ioctl for finding out which process owns the other
end of a pipe, but I'm not sure.

Cheers,
M.

-- 
  Programming languages should be designed not by piling feature on
  top of feature, but by removing the weaknesses and restrictions
  that make the additional features appear necessary.
               -- Revised(5) Report on the Algorithmic Language Scheme



More information about the Python-list mailing list