use the subprocess library:
try:
p = sh.ping("-c", "5", "www.bing.com", _bg=True, _bg_exc=False,
_out=sys.stdout, _err=sys.stderr)
p.wait()
except KeyboardInterrupt as e:
alive, _ = p.process.is_alive()
if alive:
p.process.terminate()
what are the disadvantages of this way of ending an external process?