def _kill_listen_processes(namespace, force=False):
 pids = find_listen_pids_namespace(namespace)
 pids_to_kill = {utils.find_fork_top_parent(pid) for pid in pids}
 kill_signal = signal.SIGTERM
 if force:
  kill_signal = signal.SIGKILL
  children = [utils.find_child_pids(pid, True) for pid in pids_to_kill]
  pids_to_kill.update(itertools.chain.from_iterable(children))
 for pid in pids_to_kill:
  LOG.warning(_LW('Killing (%(signal)d) [%(pid)s] %(cmdline)s'), {'signal': kill_signal, 'pid': pid, 'cmdline': ' '.join(utils.get_cmdline_from_pid(pid))[:80]})
  try:
   utils.kill_process(pid, kill_signal, run_as_root=True)
  except Exception as ex:
   LOG.error(_LE('An error occurred while killing [%(pid)s]: %(msg)s'), {'pid': pid, 'msg': ex})
 return len(pids)

def _kill_listen_processes ( namespace , force = False ) : pids = find_listen_pids_namespace ( namespace ) pids_to_kill = { utils . find_fork_top_parent ( pid ) for pid in pids } kill_signal = signal . SIGTERM if force : kill_signal = signal . SIGKILL children = [ utils . find_child_pids ( pid , True ) for pid in pids_to_kill ] pids_to_kill . update ( itertools . chain . from_iterable ( children ) ) for pid in pids_to_kill : LOG . warning ( _LW ( 'Killing (%(signal)d) [%(pid)s] %(cmdline)s' ) , { 'signal' : kill_signal , 'pid' : pid , 'cmdline' : ' ' . join ( utils . get_cmdline_from_pid ( pid ) ) [ : 80 ] } ) try : utils . kill_process ( pid , kill_signal , run_as_root = True ) except Exception as ex : LOG . error ( _LE ( 'An error occurred while killing [%(pid)s]: %(msg)s' ) , { 'pid' : pid , 'msg' : ex } ) return len ( pids )
identify all listening processes within the given namespace .