def is_alive(pidfile):
 try:
  with salt.utils.fopen(pidfile) as fp_:
   os.kill(int(fp_.read().strip()), 0)
  return True
 except Exception as ex:
  if (os.access(pidfile, os.W_OK) and os.path.isfile(pidfile)):
   os.unlink(pidfile)
  return False

def is_alive ( pidfile ) : try : with salt . utils . fopen ( pidfile ) as fp_ : os . kill ( int ( fp_ . read ( ) . strip ( ) ) , 0 ) return True except Exception as ex : if ( os . access ( pidfile , os . W_OK ) and os . path . isfile ( pidfile ) ) : os . unlink ( pidfile ) return False
check if pid is still alive .