On Thu, Sep 2, 2010 at 12:58 PM, Aahz <[email protected]> wrote:
> In article <[email protected]>,
> Astan Chee  <[email protected]> wrote:
>>Chris Rebert wrote:
>>>
>>> import os
>>> import psutil # http://code.google.com/p/psutil/
>>>
>>> # your piece of code goes here
>>>
>>> myself = os.getpid()
>>> for proc in psutil.process_iter():
>>
>>Is there a way to do this without psutil or installing any external
>>modules or doing it from python2.5?
>
> Lightly edited code I wrote yesterday:
>
>        cmd = ['ps', '-eo', 'pid,ppid']
>        output = Popen(cmd, stdout=PIPE).communicate()[0]
>        output = output.split('\n')[1:]  # skip the header
>        for row in output:
>            if not row:
>                continue
>            child_pid, parent_pid = row.split()
>            if parent_pid == str(pid):
>                child_pid = int(child_pid)
>                os.kill(child_pid, signal.SIGUSR1)

Although this doesn't meet the OP's Windows-compatibility requirement.

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to