>> to do that you need to find the process ID. I'm not sure if
>> popen() provides access to the PID but if not you could
>> either search for it (this might be too slow) or just drop
>> down to use fork rather than popen, as fork will return
>> the PID.
>
>Would calling PS via another popen() and using string methods to get
> the Pid work?

That was my initial thought but there may be better tricks available 
in pythons os arsenal, I need to take a peek....

Nope can't see anything obvious. The snag with using ps is that it 
can be easy to find duplicate processes with the same name so 
you need to check the user ID and start time against when the 
local process launched its vdersion, and its still not foolproof

Personally I'd go down the fok/exec route.
It works something like:

pid = fork()
if pid == 0:
     exec(myprog)
else:
     sleep(1)
     os.kill(pid,SIGINT)

HTH,


Alan G
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to