def is_pid_cmdline_correct(pid, match):
 try:
  with open(('/proc/%d/cmdline' % pid)) as f:
   cmdline = f.read()
   return (match in cmdline)
 except EnvironmentError:
  return False

def is_pid_cmdline_correct ( pid , match ) : try : with open ( ( '/proc/%d/cmdline' % pid ) ) as f : cmdline = f . read ( ) return ( match in cmdline ) except EnvironmentError : return False
ensure that the cmdline for a pid seems sane because pids are recycled .