def _proc_name_from_pid(pid):
 try:
  ps_output = check_output(['/bin/ps', '-p', str(pid), '-o', 'comm'])
  return ps_output.split('\n')[1]
 except CalledProcessError:
  return 'unknown'

def _proc_name_from_pid ( pid ) : try : ps_output = check_output ( [ '/bin/ps' , '-p' , str ( pid ) , '-o' , 'comm' ] ) return ps_output . split ( '\n' ) [ 1 ] except CalledProcessError : return 'unknown'
parses ps -o comm output for the given pid .