Z
Zoran Bosnjak
This simple script works with python2.1.1, but it does not work with any
newer version of python on linux. Do you think it is a bug? Where?
This program does nothing, it just suppose to end after 3 seconds,
but os.kill(...) does not kill the ping process. Even if I do it from
the shell, I need to use kill -9 <pid>.
With python2.1.1 it works as expected.
regards,
Zoran
---- cut here
import os, time, signal, threading, string
from popen2 import Popen3, Popen4
pid = 0
def run():
global pid
f = Popen4('ping localhost')
pid = f.pid
print 'pid from thread', pid
while 1:
s = f.fromchild.readline()
if not s: break
t = threading.Thread(target=run)
t.start()
time.sleep(3)
print 'timeout'
print 'pid from main', pid
os.kill(pid, signal.SIGTERM)
t.join()
print 'bye'
newer version of python on linux. Do you think it is a bug? Where?
This program does nothing, it just suppose to end after 3 seconds,
but os.kill(...) does not kill the ping process. Even if I do it from
the shell, I need to use kill -9 <pid>.
With python2.1.1 it works as expected.
regards,
Zoran
---- cut here
import os, time, signal, threading, string
from popen2 import Popen3, Popen4
pid = 0
def run():
global pid
f = Popen4('ping localhost')
pid = f.pid
print 'pid from thread', pid
while 1:
s = f.fromchild.readline()
if not s: break
t = threading.Thread(target=run)
t.start()
time.sleep(3)
print 'timeout'
print 'pid from main', pid
os.kill(pid, signal.SIGTERM)
t.join()
print 'bye'